GeeCON Prague 2014*
The moose likes Servlets and the fly likes Cannot run servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "Cannot run servlet" Watch "Cannot run servlet" New topic
Author

Cannot run servlet

Jack Lau
Ranch Hand

Joined: Aug 30, 2002
Posts: 166
Hello,
I write a servlet class and run it in my directory /WEB-INF/classes of "myapp", but tomcat shows The requested resource /myapp/servlet/HelloWorldServlet is not available.
After I put the servlet into another directory /WEB-INF/classes of "examples", it works.
Could anyone tell me how can I solve it ?
Thanks in advance!
Jack
Kareem Qureshi
Ranch Hand

Joined: Mar 14, 2002
Posts: 102
Jack,
I think it because the context root is still set to the examples folder so change the context root to point to your folder in the web.xml.
Thanks
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12792
    
    5
In order to run a servlet using the "/servlet/" syntax, as in:
/myapp/servlet/HelloWorldServlet
Tomcat has to have the "invoker" servlet turned on - look in the web.xml for the examples to see how it is done.
Prior to the current version, "invoker" was on by default, but now it is off by default (except in the examples) which is why it did not work in /myapp/
The whole idea with "invoker" was to make it easy for beginners to get started without getting involved with web.xml settings but I think it has caused more harm than good.
Download the full servlet API from java.sun.com to get the straight info on configuring web.xml.
Bill
[ May 18, 2003: Message edited by: William Brogden ]
 
GeeCON Prague 2014
 
subject: Cannot run servlet