This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I install the Apache Tomcat 5.0.28 to run my servlet class-TestServlet.
I set the parameters in the Windows 2000 system as following, "classpath" , which is ".;C:\Java\jdk1.5.0_02\lib\tools.jar;C:\Java\jdk1.5.0_02\lib\dt.jar;C:\Tomcat\common\lib\servlet-api.jar", "path", which is "C:\Java\jdk1.5.0_02\bin", and "JAVA_HOME", which is "C:\Java\jdk1.5.0_02".
I place the TestServlet.class file in the "C:\Tomcat\webapps\test\WEB-INF\classes" directory. After I started the Apache Tomcat, I use the "http://localhost:8080/test/servlet/TestServlet" URL in the IE explorer, but I got an information about "HTTP Status 404 - /test/servlet/TestServlet".
While I use a servlet example which is provided by Tomcat, It works well. For example, when I use this URL, "http://localhost:8080/servlets-examples/servlet/RequestParamExample" , it displays quite well without error information. The RequestParamExample.class locates in the "C:\Tomcat\webapps\servlets-examples\WEB-INF\classes" directory, I think its deployment is the same as my TestServlet class, but why I get this "404 error"?
Some points to add to what Ben said 1. Tomcat ignores the environment variable "classpath" 2. Your servlet class should be in a package and that package name used in the web.xml mapping. 3. Your use of "/servlet/" in the URL suggests you may be depending on the infamous "invoker" servlet. See this FAQ here at the ranch for why this is a bad idea. Bill
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.*;
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