Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
DC Dalton
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
  • 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.
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • 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.
 
rajesh karmani
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • 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.
 
Rishi Singh
Ranch Hand
Posts: 321
  • Mark post as helpful
  • send pies
  • 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
 
Mike DeStefano
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!