File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Cannot run servlet

Jack Lau
Ranch Hand

Joined: Aug 30, 2002
Posts: 168
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!
Kareem Qureshi
Ranch Hand

Joined: Mar 14, 2002
Posts: 102
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.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
In order to run a servlet using the "/servlet/" syntax, as in:
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 to get the straight info on configuring web.xml.
[ May 18, 2003: Message edited by: William Brogden ]
I agree. Here's the link:
subject: Cannot run servlet
It's not a secret anymore!