Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
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
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Servlet Mapping in Tomcat" Watch "Servlet Mapping in Tomcat" New topic

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"
reloadable="true" />
<AutoDeploy source="/home/virtual/site22/fst/var/www/html"
target="/home/virtual/site22/fst/var/www/html" redeploy="true" />
My web.xml has the following:
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:


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: 17417

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
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/

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Servlet Mapping in Tomcat
jQuery in Action, 3rd edition