Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to execute a servlet

Status
Not open for further replies.

da21

Programmer
Dec 4, 2002
23
US

Hi,
I have writtena simple servlet as under.When i compile it in the bin directory it gives me a class file. I can view both the java and the class file in the ROOT/WEB-INF/class directory, but when i try and execute it by typing HelloServlet at the URL I get no output.

public class HelloServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String docType =
&quot;<!DOCTYPE HTML PUBLIC \&quot;-//W3C//DTD HTML 4.0 &quot; +
&quot;Transitional//EN\&quot;>\n&quot;;
out.println(docType +
&quot;<HTML>\n&quot; +
&quot;<HEAD><TITLE>Hello</TITLE></HEAD>\n&quot; +
&quot;<BODY BGCOLOR=\&quot;#FDF5E6\&quot;>\n&quot; +
&quot;<H1>Hello</H1>\n&quot; +
&quot;</BODY></HTML>&quot;);
}
}

Kindly guide me through
 

Hi,

I am unable to access the directories after the ROOT directories which are ROOT/WEB-INF/classes where I have placed the HelloServlet directory containing the HellWorld.java and HelloWorld.Class file.Although I am able to execute jsp pages under the ROOT directory.
( Although I have some doubts regarding them too that I would like to clear later, if you can help me through.)

I have been strugglin with servlets past two three days.So desperately i created a servlet directory under ROOT and I was able to view both the java and the class file. But when I type in at the URL localhost:8080/classes/HelloServlet, it gives me a message that the requested resource /classes/HelloServlet is not available.

Kindly help me out I would be extremely greatfull.
 

i looked at the log file.But when i type in at the URL localhost:8080/ROOT/WEB-INF/classes/HelloServlet there is nothing happening in the log file which can guide me to some error that i am making.
 


In the log file does this message imply something that i am unable to understand.

Deploy class files /WEB-INF/classes to e:\Apache Group\Tomcat 4.1\webapps\examples\WEB-INF\classes

Thanks
 
You might want to double-check the port number that your application server uses - is it 8080 or some other port? Check your TomCat docs to verify.

HTH
 
Thank you very much for your kind response, Sir.With port no. 8080 I am able to access the Jakarta project WEB site so i am quite sure that the port no. is 8080.

One basic error that I am getting while executing a JSP page like Hello_jsp.java file present in /work/standalone/localhost/-/ directory is as under, which I had mentioned above relating JSP pages.If this someway related to servlet errors.I am unable to figer out why I am getting a back slash in the path after executing in the log file:

2002-12-20 08:41:25 Error compiling file: E:\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\hello\/hello_jsp.java [javac] Compiling 1 source file
 
It sounds like your web server and tomcat are not connected properly. Is your web server running and connected to tomcat?
 
Hi Mr Daniels,
I was out on a project tour from work.I did not understand the meaning of &quot;web server and tomcat are not connected&quot; .Because what I do every time just start the server by clicking on the 'Startup' present in the bin dorectory and the server is up.and when I type in at the web adress I get the web page of the tomcat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top