Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can't run my servlet on Tomcat 4.1.18

Status
Not open for further replies.

zhanghong920

Programmer
Nov 15, 2002
27
0
0
US
Hi all,

I've installed tomcat 4.1.18 under my account(linux machine). When I use " to access my example servlet, it has "Http status 404" error, and says "the requested resource is not available". It has the same problem when I try to access it from a html file using:
... action="/servlet/HelloWorldClass".
But the examples given by the system works.

Is there anything I missed? It's wierd because I tried the same way under tomcat 4.0.4 and it worked very well.

Thanks a lot,

Zhanghong920
 
yes, I used the port number actually:
http:// servername:my_portnumber/servlet/HelloWorldClass
and there is still the same problem:(.

Thanks,
zhanghong920

 
Define servlets ,in web.xml file located at WEB-INF folder of your application ,that are included in the your application as shown below.

<servlet>
<servlet-name>SendMailServlet</servlet-name>
<servlet-class>SendMailServlet</servlet-class>
</servlet>

Then call the servlet by the name which you have assigned to it.
 
refer to my last suggestion.Apart from defining servlet you should also do the following in the same web.xml


<servlet-mapping>
<servlet-name>SendMailServlet</servlet-name>
<url-pattern>/SendMailServlet</url-pattern>
</servlet-mapping>

Invoke the sevlet using url-pattern i.e. /SendMailServlet
 
Also, I'd check that in TOMCAT_HOME/conf/web.xml, the status of the tag line beginning <servlet-name>invoker</servlet-name>

This is the part which maps a URL such as /servlet/MyServlet to WEB-INF/classes/MyServlet

If it is commented out, then the mapping will fail.
 
Thanks all your information. I've added the <servlet-name>, <servlet-class>, as well as <servlet-mapping> into the web.xml as you suggested, and checked that the first line of &quot;invoker&quot; in the conf/web.xml is not commented out. The result is:

if I refer to my servlet as: ..., action=&quot;HelloWorldExample&quot;, or as &quot; my servlet works very well.

but if using : ..., action=&quot;servlet/HelloWorldExample&quot; instead, or as it doesn't work.

It seems that the &quot;invoker&quot; part in the conf/web.xml doesn't work, if it is used to mapping &quot;/servlet/*&quot; to the directory ..webapps/ROOT/WEB-INF/classes/*. Right now, my servlet works since the web.xml under my application directory (..webapps/ROOT/WEB-INF) surpressed the &quot;invoker&quot; part. -- It seems to me like that.

Any comments?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top