• 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

Servlet Mapping in Tomcat

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
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
If you try this:

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

What happens?
[ May 28, 2002: Message edited by: Mike Curwen ]
 
Mike DeStefano
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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/
 
Are you okay? You look a little big. Maybe this tiny ad will help:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic