• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

404 error on calling my servlet

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is servlet mapping??
Thanks
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks sir.
Ray
reply
    Bookmark Topic Watch Topic
  • New Topic