• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

HELP.....HTTP Status 404 - /servlet/TestServlet is Not Availble

 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Friends,
I'm facing strange problem.
I could not deploy a simple test.TestServlet in TomCat4.1.24
I use a new <host> for deploying.
like.... http://test.testsrv:8080/servlet/test.TestServlet

I could be able to invoke servlets in examples.
It simply says RESOURCE not availble.
What could be the reason
PLEASE HELP.
do we need to use filters to invoke a servlet?
I believe not.
Any thing I missed?

Binu
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to turn on the "invoker" servlet if you are going to use the "/servlet/" url approach. In tomcat 4 it is turned on for the examples but not in the ../conf/web.xml general web.xml file.
The single most common Tomcat 4 question - lots of discussion recently.
Bill
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey bill, I have the same problem. Acutally I just opened a topic on this one. Can you illustrate your reply a little bit more? Such as how to set up the invoker? or if I do not want to use the /servlet/* approach, how does the URL look like when invoking my servlet?
thanks
 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First off you need to make and compile the Servlet using a package. For example make the Servlet part of package app. Then put the package in the WEB-INF/app/Servlet directory. Below is an example
Example TestServlet:
package app;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class TestServlet extends HttpServlet
{
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException
{
//* your code here
}
} // end class (Servlet)
Example deployment web.xml:
<servlet>
<servlet-name>TestServlet</servlet-name>
<servlet-class>app.TestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/TestServlet</url-pattern>
</servlet-mapping>

This would allow you to access your server from http://localhost:8080/TestServlet assuming you compiled and everything went okay. You will need to restart tomcat to get the web.xml to reload. Hope this helps.
 
Elinor Chang
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That will do it. However, in my case, I'll need to prefix the name of the application that I am deploying in front of the server. So that it will look like http://host:8080/myTool/TestServlet.
Thanks!
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In order to convince Tomcat that you have a web application named "myTool" which your servlet lives in, create a myTool directory directly under webapps. myTool must in turn have a WEB-INF directory where your web.xml lives and which in turn has a classes directory.
Study the way the examples web application is set up.
Downloading the servlet API from java.sun.com is a good idea - it goes into great detail on how a web application is defined.
Bill
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic