aspose file tools
The moose likes Servlets and the fly likes Beginner question about where to put servlet for application run under Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Beginner question about where to put servlet for application run under Tomcat" Watch "Beginner question about where to put servlet for application run under Tomcat" New topic
Author

Beginner question about where to put servlet for application run under Tomcat

Susan Smith
Ranch Hand

Joined: Oct 13, 2007
Posts: 223
Hi,

I'm trying to create my first servlet.

Let say my first application, I tried to put the .class file inside /apps/servlet then I tested the URL but I got HTTP 404 error.
I also tried putting it under /apps/WEB-INF/classes but it also gives me the same error.

I have Tomcat 5.5.23

Can someone please advise?

Thanks in advance for all the help.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Classes should go under /WEB-INF/classes, following package notation. So if the class is bar.baz.MyFirstServlet.class its directory location would be /WEB-INF/classes/bar/baz/MyFirstServlet.class.

The servlet also needs to be mapped, however; mere existence in the classpath isn't enough: for example, see http://javapapers.com/servlet/what-is-servlet-mapping/ or search the web for other examples.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56228
    
  13

Have you read the Servlet Specification? If not, do so before writing another single line of code.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Beginner question about where to put servlet for application run under Tomcat
 
Similar Threads
help, where to put servelet, html, jsp file
startup.bat stops itself
How to upgrade servlets to Tomcat 5.0?
trouble with an example servlet
URGENT: How to include GPS external libraries in the project?