I had the same problem, but I followed what Ben, William and the link that William provided said. I can see "Hello World!" now.
I took the advice in the FAQ and didn't uncomment the code, instead i added the mapping to the web.xml.
Here it is the HelloWorldServlet.java:
package chapter01;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorldServlet extends HttpServlet
{
public void service(HttpServletRequest request,
HttpServletResponse response)
throws ServletException,
IOException
{
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<html>");
pw.println("<head>");
pw.println("</head>");
pw.println("<body>");
pw.println("<h3>Hello World!</h3>");
pw.println("</body>");
pw.println("</html>");
}
}
and here it is the web.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>HelloWorldServlet</servlet-name>
<servlet-class>chapter01.HelloWorldServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorldServlet</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
</web-app>
Now to the directories:
Under <Tomcat installation directory>\webapps I added a directory called Manning (it is not important what you call it). The tree (and the files) under this directory is:
Manning\WEB-INF\web.xml
Manning\WEB-INF\classes\chapter01\HelloWorldServlet.class
Now when i run it, i write:
http://localhost:8080/chapter01/hello Good luck!