| Author |
problem with HF's Ch1Servlet, pg 30 chap 1
|
Sue Pillai
Ranch Hand
Joined: Nov 04, 2004
Posts: 89
|
|
Hi guys, I remember to have done this exercise before on my computer and gotten the result page, but for some reason it is not working now. Compilation works fine since I put the servlet-api.jar file in the classpath. But when I launch the browser and type the url, there is this message: "The requested resource (/ch1/Serv1) not available" What could be the problem? Tomcat is running on port 8000 in my system and I think oracle has taken 8080. Can somebody help please. Thank you. [ January 13, 2006: Message edited by: Sue Pillai ]
|
Sue
SCJP 1.2
SCWCD 1.4
SCBCD 5.0
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
|
Have you looked in the Tomcat logs to see if any errors were reported?
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Sue Pillai
Ranch Hand
Joined: Nov 04, 2004
Posts: 89
|
|
Originally posted by Ben Souther: Have you looked in the Tomcat logs to see if any errors were reported?
I checked in the logs directory and it was empty. But in the server's startup screen, I do see a "XML validation disabled". Does that have anything to do with the problem?
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
No, Post your web.xml file. Also tell us where your files are. Specifically the servlet class file but also any other files in the application.
|
 |
Sue Pillai
Ranch Hand
Joined: Nov 04, 2004
Posts: 89
|
|
Originally posted by Ben Souther: No, Post your web.xml file. Also tell us where your files are. Specifically the servlet class file but also any other files in the application.
This is my xml file: <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2.4.xsd" version="2.4"> <servlet> <servlet-name>Chapter1 Servlet </servlet-name> <servlet-class>Ch1Servlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>Chapter1 Servlet </servlet-name> <url-pattern>/Serv1</url-pattern> </sevlet-mapping> </web-app> The servlet is: import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class Ch1Servlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { PrintWriter out=response.getWriter(); java.util.Date today=new java.util.Date(); out.println("<html>" + "<body>" + "<h1 align=center>HF\'s Chapter1 Servlet</h1>"+"<br>"+today+"</body>"+"</html>"); } } There are only two files in the tomcat directory: Ch1Servlet.class is in: c:\tomcat\jakarta-tomcat-5.5.7\webapps\ch1\WEB-INF\classes web.xml is in: c:\tomcat\jakarta-tomcat-5.5.7\webapps\ch1\WEB-INF
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
|
If you try to hit http://localhost:8000 do you see the tomcat welcome page?
|
 |
Sue Pillai
Ranch Hand
Joined: Nov 04, 2004
Posts: 89
|
|
|
yes i do
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
|
What URL are you using to access your servlet?
|
 |
Sue Pillai
Ranch Hand
Joined: Nov 04, 2004
Posts: 89
|
|
Originally posted by Ben Souther: What URL are you using to access your servlet?
http://localhost:8000/ch1/Serv1 [ January 18, 2006: Message edited by: Sue Pillai ]
|
 |
 |
|
|
subject: problem with HF's Ch1Servlet, pg 30 chap 1
|
|
|