Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Susan Smith
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you read the Servlet Specification? If not, do so before writing another single line of code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic