Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Tomcat Can't find Servlets

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I installed Tomcat 4.1.18 on both a ME & XP Home edition. The initial test page comes up fine, I have tested a few JSP's and they compile and work fine. All examples , JSP & Servlets work fine.
however, when I put a simple servlet (like a Hello World type servlet) in the classes folder,
and I access it with http://localhost:8080/servlet/HelloServlet
I get a 404 message. I've been told to check out the capitalization and spelling of the directories. They check out fine...At this point this is getting real frustrating...
I should add that I have no problem compiling the servlet and am moving the .class file into the classes directory
Thanks for any help.
[ July 23, 2003: Message edited by: john scott ]
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suspect that you havn't included your new servelts details in the web.xml document which I belive is in your web-inf directory.
The way tomcat works in regards to servlets is that you have to place the servlet information in the web.xml document so it knows when to load that information.
The url-pattern tells tomcat that if someone goes to to load this serverlet.
Posts: 67425
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) You need to turn the servlet invoker on in the server.xml file. Details have been covered a few times in this forum.
2) You also need to put your classes in packages. Most containers have trouble finding classes in the default package.
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should never be necessary to declare your .jsp files explicitly in web.xml the way Adam describes. Servlets yes, but JSPs no. The name of the class that the JSP compiles to is not something you should normally need to know, and I think it's container-dependent anyway.
Servlets don't need to be in packages, but beans that are used in JSPs do need to be in packages.
[ July 23, 2003: Message edited by: Ron Newman ]
Author and all-around good cowpoke
Posts: 13078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I recall, the invoker servlet can find servlets that are not in classes, but Tomcat has a problem otherwise - something about classes in the "default" package assumed to be in the "current" directory.
The best policy is to always put servlets and helper classes in packages.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic