File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes tomcat-4.1.24 configuration problem? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "tomcat-4.1.24 configuration problem?" Watch "tomcat-4.1.24 configuration problem?" New topic
Author

tomcat-4.1.24 configuration problem?

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I have an application, SampleApp, under webapps directory in tomcat-4.1.24 environment. I am able to access my app (which is just one servlet) as:
http://localhost:8080/SampleApp/servlet/SampleServlet
My confusion is about:
1) Why should I use http://localhost:8080/SampleApp/servlet/SampleServlet to access the servlet instead of using http://localhost:8080/SampleApp/SampleServlet (i.e. without /servlet in the URL)? Where is this configured? How to make this work without /servlet in the URL?
2) Looks like the web.xml file for my app (in <whatever>/webapps/SampleApp/WEB-INF/web.xml) is not being read. For example, I have the following in web.xml:
<servlet>
<servlet-name>SampleServlet</servlet-name>
<servlet-class>SampleServlet</servlet-class>
<run-as>
<description>Security role for anonymous access</description>
<role-name>tomcat</role-name>
</run-as>
</servlet>
When I call
String myServletName = getServletConfig().getServletName();
it throws an exception instead of getting the name of the servlet from web.xml. I have tried shutting down tomcat server, adding all kinds of extraneous stuff to web.xml, rebooting the machine, etc. Problem still exists. What am I doing wrong here?
Thanks in advance for your help.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
just add the following entry to your web.xml

Then you can reach it under http://yourMachine/yourApp/sampleservlet
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Thanks, Oliver...confusion 1) is cleared.
2) is still a problem.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
When you address a servet using the /servlet/yourservlet approach, it is the invoker servlet that loads the class and runs it.
The use of invoker causes all sorts of bizarre problems - you would be much better off to get your web.xml set up correctly so that you can address it directly and the servlet engine sees your servlet as a real web application.
Bill
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: tomcat-4.1.24 configuration problem?