aspose file tools*
The moose likes Tomcat and the fly likes Servlet doesn't work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Servlet doesn Watch "Servlet doesn New topic
Author

Servlet doesn't work

Yosi Hendarsjah
Ranch Hand

Joined: Oct 02, 2003
Posts: 164
Hi,
It's been years since the last time I used Tomcat. Now I'm using it again because I'm preparing for the SCWCD exam. I have created a simple servlet and deployed it to Tomcat but it doesn't work. I put the class file in <tomcat-dir>/webapps/myapps/WEB-INF/classes directory. I have created the web.xml file:


I have also set the JAVA_HOME, CATALINA_HOME, and the classpath to the file servlet.jar. But when I try to invoke the servlet using a browser by typing http://localhost:8080/myapps/servlet/myservlet, it shows HTTP status 404. What have I done wrong? Have I missed something?
[ November 02, 2004: Message edited by: Yosi Hendarsjah ]
Joyce Lee
Ranch Hand

Joined: Jul 11, 2003
Posts: 1392
Hi Yosi,

Which version of tomcat are you using? For Tomcat 5.0.28 or 5.XXX, the servlet api should be servlet-api.jar instead of servlet.jar. Tomcat 5 is based on Servlet 2.4 and JSP 2.0. Have you uncommented the <servlet> and <servlet-mapping> elements for the invoker in c:\tomcat\conf\web.xml. Also, if you've a servlet.jar under C:\jdk1.5.0\jre\lib\ext, remove or place the jar file in a temporary directory.

For more info on setting up Tomcat 5, you could check out CoreServlets: Installing Tomcat 4 or 5.

Joyce
[ November 02, 2004: Message edited by: Joyce Lee ]
Yosi Hendarsjah
Ranch Hand

Joined: Oct 02, 2003
Posts: 164
Hi Joyce,
My Tomcat version is 4.1.24. My JVM version is 1.4.2_05
[ November 02, 2004: Message edited by: Yosi Hendarsjah ]
Joyce Lee
Ranch Hand

Joined: Jul 11, 2003
Posts: 1392
Hi Yosi,

I suggest you use Tomcat 5.0.28 since the latest SCWCD exam is based on Servlet 2.4 and JSP 2.0 specifications. As for the JDK, you can still use the 1.4 version.

Joyce
[ November 02, 2004: Message edited by: Joyce Lee ]
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Invoker servlet. http://faq.javaranch.com/view?InvokerServlet
Yosi Hendarsjah
Ranch Hand

Joined: Oct 02, 2003
Posts: 164
Thanks, Mike! The book I'm reading (Desmukh & Malavia) doesn't mention those.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet doesn't work
 
Similar Threads
Unable to get EL to work
Unable to set up Init Params
web.xml error page
web.xml error page
Run Servlet In Eclipse