File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes Servlets not working under Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Servlets not working under Tomcat" Watch "Servlets not working under Tomcat" New topic

Servlets not working under Tomcat

Michael Sullivan
Ranch Hand

Joined: Dec 26, 2003
Posts: 235
Okay, I did research on this, but alas I need another pair of eyes.
From this page:
In the file conf/web.xml find a section of text that looks like this:
<!-- The mapping for the invoker servlet -->
You need to uncomment the servlet-mapping and then restart Tomcat to allow all servlets to work.

Yes, I know that this is a security risk, however since I'm going through a textbook that supplies code for many, many servlets... I don't want to add mapping for each of them since this isn't for production (or even development) but for training purposes. However I find myself in a bind-when I save and HelloWorld.class file to root/web-inf/classes and then try to call the servlet by:
I get the infamous: The requested resource (/servlet/HelloWorld) is not available.
so, what could be wrong? I should be correct in assuming that by uncommenting the servlet invoker that I should be able to type in: http://localhost ort/servlet/servletName and access the servlet, no?
I've been all over the Jakarta site, and to tell you the honest truth, Java Ranch is a lot more user friendly... which is how I ended up here (again).
I've even tried to place it in the servlets-examples directory, and modified the appropriate web-xml file with the following mapping:
and even this:
But still, no love. Unfortunately, its too late at this hour to head out to the bookstore and reference one of the Sun Core JSP and Servlet texts, so I thought to ask here. Any ideas?
Michael Sullivan
Ranch Hand

Joined: Dec 26, 2003
Posts: 235
well, not sure what to make of this. Went to the bookstore and referenced a couple of texts that note that Tomcat is more difficult to config than the other servers. I tried mapping my servlets with no effect, and changed various server.xml and web.xml settings... also in vain.
I had previously downloaded Resin, and unzipped that, made one slight change to the server.xml file and presto! Servlets working fine. Strange.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
Tomcat seems simple to configure to me. It follows the published servlet API exactly.
It is the use of the invoker servlet that has led people astray many times - primarily because earlier versions had it on by default and the introductory books used it.
If you are using the invoker servlet, you don't need to define anything in web.xml but the invoker - just make sure your class files end up in the right place.
I agree. Here's the link:
subject: Servlets not working under Tomcat
It's not a secret anymore!