• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you read the Servlet Specification? If not, do so before writing another single line of code.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic