On 09/07/2021 08:23, Olaf Kock wrote:

On 09.07.21 07:58, Jerry Malcolm wrote:
I have one webapp that processes REST-style url paths and therefore
needs to run in the ROOT context.  Is it possible to run other webapps
in the same host with other non-root contexts?   In other words, when
resolving a URL to a web app, does it try to map the url to the
defined context strings first, and then to ROOT if there are no
matches?  Or does ROOT override everything, and all URLs go to ROOT if
it's defined?

If memory serves me well and this behavior didn't change in the past
decade, then all other web applications have precedence over root. That
is, if you deploy ROOT.war and json.war (and assume the context-path to
be /json), then your root application's /json path would never be reached.

It's easy to visualize this way around, because it's an absolutely
static mapping with the size being "number of webapps", while the other
way around, ROOT could also map /* to one of its servlets and then
determine what to do it. The spec has to means to explicitly hand a
request back to the appserver and every app would rather generate 404
than check if somebody else might be there to handle it.

To put it another way, when mapping a request to a web application Tomcat:
- normalises the request URL
- routes the request to the web application with the longest matching
  context path

The exact wording is in section 12 of the Servlet specification.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to