File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

404 error on calling my servlet

 
Ray Smilgius
Ranch Hand
Posts: 120
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 120
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am at home now when I get back to work I will try this.

Thanks very much
 
Ray Smilgius
Ranch Hand
Posts: 120
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is servlet mapping??
Thanks
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 120
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks sir.
Ray
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic