It's not a secret anymore!
The moose likes Servlets and the fly likes servlet not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet not working" Watch "servlet not working" New topic

servlet not working

siva raman

Joined: Sep 15, 2003
Posts: 5
Dear programmers,
I am just now learning servlets using Tomcat . I wrote a small HelloWorld programe and kept it in the root dir of the server. But when i try to access this servlet by giving the URL
http://localhost:8080/servlet/servlet_name Iam getting the error message that this servlet could not be found.
when I try the examples given along with the Tomcat, everything works fine.
Why is this.I have also created the dir as said in the documentation.
thanking you,
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
In tomcat you have to deploy your web application into $TOMCAT_HOME/webapps/. Copy there your war file or your
directory with the appropriate structure (incl. WEB-INF, META-INF).
There you also have to define your web.xml (descriptor of your webapplication)
Check out this tutorial
Gayathri Prasad
Ranch Hand

Joined: Jun 25, 2003
Posts: 116
If ur trying to check a simple Servlet then follow this
in ur tomcat home directory
i.e tomcat4.1->webapps->examples->WEB-INF->classes
put ur servlet class files here and access them thru ur container as u access the example servlets.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
The url nomenclature that uses "servlet/" uses the "invoker" servlet to find the actual servlet class. Tomcat used to come with this servlet on by default so you see it used in books alot. However, for Tomcat 4 the invoker is off in the ROOT application and on in the examples.
Search the web.xml file in the conf directory for "invoker" to see more documentation. This question comes up ALOT - several times a week, so look at the recent posts.
I agree. Here's the link:
subject: servlet not working
jQuery in Action, 3rd edition