jQuery in Action, 3rd edition
The moose likes Servlets and the fly likes simple question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "simple question" Watch "simple question" New topic

simple question

Ravi Sathish
Ranch Hand

Joined: Feb 26, 2002
Posts: 131
I am newbie to Servlets, JSP and Tomcat.
all I want to do is run my servlet HelloWorldServlet on the browser
i.e: http://localhost:8080/servlet/HelloWorldServlet
I am getting http status 404 error:
type: Status report
message /servlet/HelloWorldServlet
description The requested resource (/servlet/HelloWorldServlet) is not available
I have HelloWorldServlet.class in
C:\Program Files\Apache Tomcat 4.0\webapps\examples\WEB-INF\classes
My classpath:
C:\Program Files\Apache Tomcat 4.0\webapps\ROOT\WEB-INF\classes;C:\Program Files\Apache Tomcat 4.0\common\lib\servlet.jar;
My tomcat_home:
C:\Program Files\Apache Tomcat 4.0\bin
Any help is appreciated
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
try to put your servlet into a package. Then you should be able to
request it via http://machine ort/servlet/package/Servlet.
Amit KumarS
Ranch Hand

Joined: Oct 10, 2003
Posts: 100
Hi Ravi...
try this URL in your browser
and if this doesn't work (it has to work if there is nothing else wrong... ) then check ur Web.xml file inside your WEB-INF directory.
there should be two entries..

hope this helps you... in case of dooubt please revert back..

****************************<br />In 24 hrs Earth rotates once on its Axis.
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Based on where your classes are, this should work.

As already posted though, it's better to have a web application and then use its web.xml to configure how your servlets are accesed.

So much trouble in the world -- Bob Marley
swapna Kadali

Joined: Oct 06, 2003
Posts: 22
Hi, I had the same problem and even i am new to all those u mentioned.
But i solved that problem by making sure whether the tomcat installation is done properly, check the port where ur running the tomcat server first.
I use NetBeans IDE, so i exported a war file including all files and dropped in tomcat's webapp's folder and then browse.
http://localhost:8080/warfilename/path in URL mapping of web.xml file
It should work, hope it would help for you.
swapna Kadali

Joined: Oct 06, 2003
Posts: 22
In general, it is suggested you to install tomcat in

C:/Jakarta/Tomcat4.0 ( according to my professor) without any blank spaces in the folder.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

By default, in Tomcat 4 and later, you can't invoke a servlet that's not defined in a web.xml file (no drop-and-go). This is a security feature.

An IDE is no substitute for an Intelligent Developer.
Ravi Sathish
Ranch Hand

Joined: Feb 26, 2002
Posts: 131
Thanks for all the help.
I did not restart my server after registering my servlet.
rashu gulati

Joined: Nov 06, 2003
Posts: 12
I joined the forum today only .Hope my answer helps you out.All you need to do is to have a web.xml file in /mainwebapp/WEB-INF which will look something like this.
All u have to do is to replace the assignmentCookie by your file name.
Hope it helps you.
I agree. Here's the link: http://aspose.com/file-tools
subject: simple question
It's not a secret anymore!