aspose file tools*
The moose likes Tomcat and the fly likes Servlet Mapping in Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Servlet Mapping in Tomcat" Watch "Servlet Mapping in Tomcat" New topic
Author

Servlet Mapping in Tomcat

Mike DeStefano
Ranch Hand

Joined: May 24, 2002
Posts: 36
Hello... I appreciate any help I can get on this. I've been struggling to keep my sanity for the past couple of weeks while working on the following problem.
I mapped a kew URLs to a servlet in my web.xml doc, and had no problem. For example, when I went to http://localhost/<webapp>/welcome, it directed the request to my Controller servlet as it was supposed to.
I thought it was easy until I uploaded the application to the internet, - and found it did not work as planned. When I went to http://<host>/welcome, it could not find the address, and gave me a 404 Not Found error.
My host has set me up as follows (from the server.xml, I believe):
<Host name="www.<host>" >
<Alias name="<host>" />
<Context path="" docBase="/home/virtual/site22/fst/var/www/html"
reloadable="true" />
<AutoWebApp dir="/home/virtual/site22/fst/var/www/html"
host="www.<host>"
reloadable="true" />
<AutoDeploy source="/home/virtual/site22/fst/var/www/html"
target="/home/virtual/site22/fst/var/www/html" redeploy="true" />
</Host>
My web.xml has the following:
<servlet>
<servlet-name>
Controller
</servlet-name>
<servlet-class>
util.Controller
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>
Controller
</servlet-name>
<url-pattern>
/welcome
</url-pattern>
</servlet-mapping>
My host company is running a shared instance of Tomcat 3.3. What, if anything am I doing wrong?
I'm grateful for anyone who can spare my sanity.
Thanks alot,
- Mike


-Mike Destefano<br />"Sometimes you feel like a nut..."
Mike DeStefano
Ranch Hand

Joined: May 24, 2002
Posts: 36
Is there additional information I need to get from my web host in order to solve this problem? Or do they have to configure something on their end?
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

If you try this:

http://<host>/<webapp>/welcome

What happens?
[ May 28, 2002: Message edited by: Mike Curwen ]
Mike DeStefano
Ranch Hand

Joined: May 24, 2002
Posts: 36
Thank you for your quick reply...
Your solution makes a lot of sense, but is there anyway to know what my <webapp> is, when my host only provides me with a simple directory or virtual host?
The directory I put my jsps and web-inf folder is:
/home/virtual/site22/fst/var/www/html... I only really have access to var/www/html.
Do I have a <webapp> in this case?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

Your "webapp" is the "path" in the Context declaration, and you have that declared as "" - which is to say no context. That makes it the primary webapp on that host.
I'm presuming that <host> ism't your REAL host name, since I doubt that's even legal in a URL, but the applet retrieved by http://www<host>/welcome should resolve as follows:
1. lookup the servlet ID for the URL. This gives a servlet name of "Controller"
2. lookup the class that implements "Controller", which in your case would be "util.Controller"
3. Use the filepath from web.xml for this servlet context to locate util.Controller. This gives
/home/virtual/site22/fst/var/www/html/WEB-INF/class/util/Controller.class
Assuming you didn't put the util.Controller in a JAR file, which would be stored /home/virtual/site22/fst/var/www/html/WEB-INF/lib/


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet Mapping in Tomcat