tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: two responses from one request - how is it possible ?
Date Wed, 24 Apr 2013 08:45:16 GMT
André Warnier wrote:
> 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>
> Host: somehost.company.com<CR/LF>
> ..
> 
> The "Host:" header is examined first, to find out to which configured 
> Tomcat <Host> this 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 URL 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.
> 
addendum : and (as this was an unfunished draft)
I should have added that each non-ROOT context also has a default servlet, inherited from

the default (catalina_base)/conf/web.xml.
So if within a context no appropriate <url-mapping> can be found for this request to
this 
context, the request will be processed by the default servlet of that context, which will

look for a file on disk to satisfy the request.  And if it doesn't find one, it will 
return a 404 error.

I should also have added that the URL-mapping as described above is a bit rough, and that

the Servlet Spec explains more accurately how this is done.

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


Mime
View raw message