File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes HTTP status error 404 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "HTTP status error 404" Watch "HTTP status error 404" New topic

HTTP status error 404

Sen George
Ranch Hand

Joined: Sep 21, 2005
Posts: 76
I am new to servlets. I am using Tomcat version 5.5. I am trying to run a simple servlet. The class file is under \tomcat\tcat-5.5\webapps\ch1\WEB-INF\classes. I have placed the deployment descriptor file under tomcat\tcat-5.5\webapps\ch1\WEB-INF\. I restarted Tomcat after copying the two files.

When running the command http:localhost:8080/ch1/myserv1, I get the following error.
HTTP Status 404 - /ch1/myserv1
type Status report
message /ch1/
description The requested resource (/ch1/myserv1) is not available.

I trust the problem is with relating the directory ch1 with Tomcat. Please advise what needs to be done.

Sen George
Ranch Hand

Joined: Sep 21, 2005
Posts: 76
Please ignore the tags <HR> and </HR> in the error message. Apologize for that.

Neeraj Dheer
Ranch Hand

Joined: Mar 30, 2005
Posts: 225
can you please post your web.xml file?
Sen George
Ranch Hand

Joined: Sep 21, 2005
Posts: 76
Here is the web.xml file.

<web-app xmlns=""
<servlet-name>Chapter1 Servlet</servlet-name>
<servlet-name>Chapter1 Servlet</servlet-name>
Rajesh Vijaya
Ranch Hand

Joined: Oct 18, 2005
Posts: 48
hi San ,

in the xml file in the url-pattern

try this


when you use forward slash it will be relative to the context root ( in this case ch1)

besides in url type :




Rajesh <br /> <br />SCJP1.4 SCWCD1.4 SCBCD 1.3 ,SCDJWS(Preparing..)<br /> <br />There is no free will.It is the phenomenon bound by cause and effect.But there is something behind will which is free---Swami Vivekananda...
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036

Generally speaking you will save yourself a LOT of trouble if you put ALL classes involved with servlets in packages. The directory structure under WEB-INF/classes will have to reflect the package structure.
Sen George
Ranch Hand

Joined: Sep 21, 2005
Posts: 76

It worked. The issue was with the missing forward slash in the URL pattern tag. I hope it is OK to raise a related question here.

What setting makes Tomcat to look for an application root (ch1 in my example) under webapps directory and not under bin or temp directory for example?

Thanks once again for the help.

I agree. Here's the link:
subject: HTTP status error 404
It's not a secret anymore!