• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Third Party WebApplication Has Servlet-Name 'default' in web.xml

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I deployed a third party web application that has servlet-name 'default' in web.xml, in Tomcat 6.
Tomcat already use that servlet name, you can see $CATALINA_HOME/conf/web.xml. How Can i use that web application at minimal changes.
 
Saloon Keeper
Posts: 28126
198
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
I don't think that the Tomcat default servlet has a namespace conflict with the webapp. In fact, I'm pretty sure that if a URL routing rule routed to a servlet whose logical name was "default" and there was no local (web.xml) pairing of that name with a class within the webapp's classpath it would result in an error. There's nothing I know of in the J2EE standard that assures that there will be a servlet named "default" in every J2EE-compliant webapp server.

Tomcat's processing of URLs goes something like this:

First the URL is converted to server-local form so that the "http://hostname:port" part of the URL doesn't get considered as part of the matching process. So the matched path for "https://www.myserver.com/mywebapp/servlet1" would reduce to simply "/mywebapp/servlet1".

This normalized URL is then matched against the list of application contexts for deployed webapps in the server.

Then the URL under scan is further reduced to app-relative form. Meaning that "/mywebapp/servlet1" becomes "/servlet1".

This reduced URL is matched against the list of servlet URL patterns provided in that webapp's WEB-INF/web.xml.

If the reduced URL matches one of the web.xml patterns, that pattern is used as the key to locate the servlet's logical name, which is in turn used to locate the servlet class instance based on its classname. At that point the URL request is handed over to the matched servlet.

In the event of no match, THEN Tomcat will attempt to find a JSP whose resource path matches the reduced URL. If it finds one, the JSP will be compiled to create a servlet (or a previously-compiled copy will be located) and the URL request is sent there.

If neither webapp servlet pattern or JSP resource path match, then and only then will Tomcat attempt to process the request itself, using the master web.xml that's part of Tomcat itself (and which almost NEVER should be customized). The master web.xml will direct the unwanted URLs to Tomcat's internal default servlet, which will itself go through a set of attempts to resolve the URL, ending with the infamous "404" page, if nothing better can be done.
 
get schwifty. tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic