A container uses the mapping rules defined by the servlet specification to map an incoming request URI to the appropriate context and servlet that will process the request.

In this section, we will explore these rules and then discover how this mapping is implemented within Tomcat.

Mapping rules

The target context is determined based on the longest context path on the URL that matches one of the contexts for the specified virtual host.

Once a successful context match has been found, the remainder of the URL, up to the query string, is considered for a match with the wrappers associated with that context. Each of the rules below is tried, in a case sensitive manner, until the first match is found, at which point the matched wrapper is returned. ...

Get Tomcat 6 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.