Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlets don't start in tomcat 4.1

 
A. Mazon
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to make some tests using servlets in Tomcat 4.1.18 but I recieved an error and I can't figure out why.

The error is the 404. I have my servlet class in the directory "webapps\mywebapp\WEB-INF\classes\mypackage\"
And I am trying to access it using the following URL: "http://localhost:8080/mywebapp/servlet/mypackage.ServletName
but it doesn't work . I was using some examples from a book but those dont work either.
Does anybody know what am I doing wrong? Since I can load the servlet examples that come with Tomcat I guess I am missing something.
Thank you in advance.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We get this one alot!
In order to use the /servlet/ style of addressing a servlet you need to have the "invoker" servlet turned on in the particular web application. See the web.xml in the examples to see it in use.
The /servlet/ thing is supposed to be a "convenience" item and was turned on by default in Tomcat for earlier versions. In the current version it is turned off. Look also at the web.xml in /conf
Bill
 
A. Mazon
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bill,
I decided to use Tomcat 4.0 which is the version that comes with the CD I have and it is working fine. I will have to read the documentation to try to make the things work in the 4.1 version but for now I am ok with the old one.
Thank you!
 
Louise Haydu
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just downloaded and installed Tomcat 4.1.24 and am also receiving 404 errors when I attempt to run servlets.
The "invoker" tags are not commented out in the config\web.xml file.
Here's info on my problem:
servlet class location: "webapps\chapter01\WEB-INF\classes\HelloWorldServlet.class"
web.xml: contains tags to define the HelloWorldServlet
URL used to access: "http://localhost:8080/chapter01/servlet/HelloWorldServlet"
I am using the SCWCD Exam Study Kit book, which contains a CD that has complete workable files for this HelloWorldServlet.
So I decided to use install the Tomcat 4.0 version supplied on the CD in the book and now everything works fine.
Does anyone have any additional insight on the problems I experienced with Tomcat 4.1.24?
Thanks!
Louise
 
Louise Haydu
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found my problem... when I looked in the conf\web.xml file, I wasn't looking in the right place for the "invoker" tags. The tags that need to be uncommented are as follows:
<!-- The mapping for the JSP servlet -->
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
Everything is working fine now!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic