tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: two responses from one request - how is it possible ?
Date Wed, 24 Apr 2013 08:33:04 GMT
Shanti Suresh wrote:
> André
> Please kindly share the half-page that you have written up so far.
> Actually, would you please finish it up and then post?

Well, here you go. Luckily, it was still in my drafts folder.
Remember that it was a draft, and that a more accurate explanation is available in the 
Servlet Spec.

A HTTP request looks like this :

GET /the_url.. HTTP/1.1<CR/LF>

The "Host:" header is examined first, to find out to which configured Tomcat <Host>
request is addressed. If a matching Host is found, then this will be the one which 
processes this request further.  If none is found, then the request will be processed by 
Tomcat's default <Host> (the one named in the <Engine> tag).

Then comes the evaluation of the URL ("/the_url..").
Within the selected <Host>, Tomcat will first attempt to match the first part of the
with (the path of) one of the (non-ROOT) defined contexts.  If a match is found, the 
request will be passed to that context for processing (*).
If no match is found, and there is no default context defined, then Tomcat will return an

error to the client.
If there is a default context defined, then Tomcat will pass this request to the default 
context (the one under (appBase)/ROOT) for processing.  Within that default context, a 
match will then be attempted with any of the <url-mapping> elements of that default

context. If a mapping is found, the request will be passed to the corresponding servlet 
for processing.
If no mapping is found, the request will be passed to the default servlet of the default 
context for processing.  That one attempts to find a file on disk within the default 
context, which matches the path indicated by the URL. If it finds one, the file will be 
returned as the response. If no such file is found, a 404 error will be returned.

(*) within a matching context, there will be further matching of the second part of the 
URL, with one the defined servlet's <url-mapping> elements.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message