File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Problem accessing servlet through Tomcat 5.0.28 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 "Problem accessing servlet through Tomcat 5.0.28" Watch "Problem accessing servlet through Tomcat 5.0.28" New topic
Author

Problem accessing servlet through Tomcat 5.0.28

Adam Dear
Greenhorn

Joined: Oct 21, 2003
Posts: 13
I am trying to set up tomcat on my dev. server. I am having trouble getting my servlets to work. I have tried to follow the directions for Tomcat 5 on its site, but they are kind of confusing. I also have a servlet book, but it talks about Tomcat 4. something. Is there a big difference between 4 and 5? Anyway, when I try to view a servlet, the server gives a HTTP 404 error, and says the resource is not available.

Here is what I have done:

1. linked apache and tomcat with mod_jk2. This is working fine for jsp
2. created dir. structure tomcat\webapps\myApp\WEB-INF\classes.
3. saved and compiled servlet to classes subdirectory.
4. created web.xml descriptor in web-inf directory.
5. access the servlet at http://localhost:8000/8080/myApp/servlet/Servlet
port 8000 is the tomcat port, and 8080 is the apache port

This gives the 404 error everytime I try to access the servlet.

I am able to access the admin and management part of tomcat so I know it is working, and my .jsp pages also work, just not the servlets.

Can anyone help???
Thanks
[ October 25, 2004: Message edited by: Adam Dear ]
Joyce Lee
Ranch Hand

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

Assuming you could see the Tomcat main page by accessing the http://localhost:8080. Did you uncomment the servlet and servlet-mapping elements in tomcat/conf/web.xml?

For more info, you can check out CoreServlets: 6. Enable the Invoker Servlet.

Joyce
[ October 25, 2004: Message edited by: Joyce Lee ]
Joyce Lee
Ranch Hand

Joined: Jul 11, 2003
Posts: 1392
5. access the servlet at http://localhost:8000/8080/myApp/servlet/Servlet

How about you try http://localhost:8000/myApp/servlet/ServletName? where ServletName is the servlet you wish to run.

Joyce
Adam Dear
Greenhorn

Joined: Oct 21, 2003
Posts: 13
Thanks for the suggestions. I finally got it to work by adding a <servlet-mapping> element to the application web.xml file.

thanks again!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem accessing servlet through Tomcat 5.0.28
 
Similar Threads
Help to find the error.
How to deploy my own webapplication
Apache -> Tomcat servlet problem
simple question
problem with servlets