• 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Servlet mapping in tomcat w/o access to server.xml

 
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there any way to set up servlet mapping in Tomcat when you dont have access to the server.xml file. Im running on a shared instance of tomcat & we only have access to the web.xml. We have set that up right but the servlets are still not found, then I read somewhere that BOTH the server.xml & the web.xml need to show the mapping. Any help at all would be much appreciated as this is just as frustrating as it can be.
 
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should only need to add the mapping to your web.xml file.

If this is in the path webapps/<your application root>/WEB-INF then you would call the servlet with http://hostname/<your application name>/controller.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah quite right, mapping is only added to web.xml of ur application which is present in the web-inf folder. May be if u r using tomcat try creating a new application because sometimes it has problems.
 
Ranch Hand
Posts: 321
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
U can try adding a new application , which does not requires any entry in the server.xml, jst make the entry in the web.xml under <servlet>
and <servlet-mapping> and restart the server.If this does not solve the purpose try using another instance of 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
I have tried myself to map a URI to a servlet, but am having partial success. On my machine, it works, but when I upload the application, the URI is not directed to the servlet.
My web.xml servlet mapping looks like this:
<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>
If I go to http://localhost/<appname>/welcome, this works... The Controller servlet is found. When I upload the application and try http://<hostname>/welcome, it fails miserably with a 404 NOT FOUND message. The mapping is simply not working on the internet, but is, on my PC. I cannot see my mistake.
My Controller serlet is in WEB-INF/classes/util folder. The web.xml is in WEB-INF.
I've even had the administrators of the server give me the context info from server.xml. But this hasn't shown me what the problem is either.
<Host name="www.<hostname>" >
<Alias name="<hostname>" />
<Context path="" docBase="/home/virtual/site22/fst/var/www/html"
reloadable="true" />
<AutoWebApp dir="/home/virtual/site22/fst/var/www/html"
host="www.<hostname>"
reloadable="true" />
<AutoDeploy source="/home/virtual/site22/fst/var/www/html"
target="/home/virtual/site22/fst/var/www/html" redeploy="true" />
</Host>
I'm thinking of scrapping the servlet mapping and pointing directly to the servlet in lite of the situation.
I hope someone out there has an answer as to why it works off line, but not online.
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tomcat has a default web app called ROOT. Unless you are placing your web application there, I believe that you still have to include the /<app-name> in your url.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic