Hi guys,
This is a repeat question. If you have seen my posting in
servlets board pls ignore it. I am just desparate to get an answer and thought this would be a good place to post too.
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 there is this message:
"The requested resource (/ch1/Serv1) not available"
My logs directory does not have any error messages and is empty.
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
The url I use is :
http://localhost:8000/ch1/Serv1 and I do see the welcome page if I type
http://localhost:8000 (Tomcat is running on port 8000 in my system and I think oracle has taken 8080.)
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>");
}
}
What could be the problem? Can somebody help please.
Thank you.