File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes 404 error on calling my servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "404 error on calling my servlet" Watch "404 error on calling my servlet" New topic
Author

404 error on calling my servlet

Ray Smilgius
Ranch Hand

Joined: Jan 29, 2001
Posts: 120
wheni try to run my own servlets on newly installed Tomcat , for eg with following settings:
In folder %Tomcat_Home%\webapps\FortKnox folloing files are there :
- index.jsp
- WEB-INF\classes\pleasework.class
- WEB-INF\web.xml

C:\jarkarta-tomcat-4.0\webapps\FortKnox\WEB_INF\classes //my servlet is here called 'pleasework.class'


//web.xml file below
<web-app><servlet><servlet-name>serve</servlet-name><servlet-class>pleasework</servlet-class></servlet></web-app>
my port has been changed to 80 instead of 8080
Now when i request : <http://localhost/FortKnox>
tomcat responds with 'index.jsp' correctly

But when i request : <http://localhost/FortKnox/servlet/serve>
Browser 404 file not found:
//also I tried this as well.
<http://localhost/FortKnox/serve>
Browser 404 file not found:
------------------
Sun Certified Java Programmer
Sun Certified Java Developer
I-Net Certified
A+ Certified
Network+ Certified
MCP
[This message has been edited by Ray Smilgius (edited November 19, 2001).]
[This message has been edited by Ray Smilgius (edited November 19, 2001).]


SCJO, SCJD, SCWCD, I-Net+, A+, Network+, MCSD, MCDBA, MCP, MCT
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Do you have a servlet mapping?

You need two pieces, because it uses that 'ole double indirection.

<servlet>
<servlet-name>serve</servlet-name>
<display-name>optional</display-name>
<servlet-class>pleasework</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>serve</servlet-name>
<url-pattern>servePattern</url-pattern>
</servlet-mapping>
That should make http://localhost/FortKnox/servePattern
serve up the 'serve' servlet, which is the 'pleasework' class file.
Ray Smilgius
Ranch Hand

Joined: Jan 29, 2001
Posts: 120
I am at home now when I get back to work I will try this.

Thanks very much
Ray Smilgius
Ranch Hand

Joined: Jan 29, 2001
Posts: 120
What is servlet mapping??
Thanks
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

A servlet mapping 'maps' an URL pattern to a particular servlet.

Suggested reading: http://www.jcp.org/aboutJava/communityprocess/final/jsr053/
The servlet spec, which explains some of this...
http://java.sun.com/j2ee/dtds/web-app_2_2.dtd
The DTD for web.xml (don't bother with ie, use Netscape to view this one)
[This message has been edited by Mike Curwen (edited November 20, 2001).]
Ray Smilgius
Ranch Hand

Joined: Jan 29, 2001
Posts: 120
Thanks sir.
Ray
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 404 error on calling my servlet
 
Similar Threads
trying to get a simple bean example to work using Tomcat and jsp
Error 404 with servlet in Tomcat
fowarded from servlet to jsp but in the browser it shows the servlet name???
is this web.xml correct
jsp when compiled cant find bean class see code servlet exception