• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTTP status error 404

 
Sen George
Ranch Hand
Posts: 76
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 76
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please ignore the tags <HR> and </HR> in the error message. Apologize for that.

Sen.
 
Neeraj Dheer
Ranch Hand
Posts: 225
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you please post your web.xml file?
 
Sen George
Ranch Hand
Posts: 76
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13048
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 76
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic