aspose file tools*
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
Author

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.
<HR>
HTTP Status 404 - /ch1/myserv1
type Status report
message /ch1/
description The requested resource (/ch1/myserv1) is not available.
</HR>

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

Sen.
Sen George
Ranch Hand

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

Sen.
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="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
web-app_2_4.xsd"
version="2.4">
<servlet>
<servlet-name>Chapter1 Servlet</servlet-name>
<servlet-class>Ch1Servlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Chapter1 Servlet</servlet-name>
<url-pattern>myserv1</url-pattern>
</servlet-mapping>
</web-app>
Rajesh Vijaya
Ranch Hand

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

in the xml file in the url-pattern

try this

<url-pattern>/myserv1</url-pattern>

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

besides in url type :

http://localhost:8080/ch1/myserv1

Rajesh

SCJP1.4


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
Rancher

Joined: Mar 22, 2000
Posts: 12803
    
    5

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.
Bill
Sen George
Ranch Hand

Joined: Sep 21, 2005
Posts: 76
All,

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.

Regards,
Sen.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HTTP status error 404