Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with HF's Ch1Servlet, pg 30 chap 1

 
Sue Pillai
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked in the Tomcat logs to see if any errors were reported?
 
Sue Pillai
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you try to hit http://localhost:8000 do you see the tomcat welcome page?
 
Sue Pillai
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i do
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What URL are you using to access your servlet?
 
Sue Pillai
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic