tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: URI mapping
Date Sun, 23 Oct 2011 23:39:08 GMT
Mark Eggers wrote:
> ----- Original Message -----
>> From: André Warnier <>
>> To: Tomcat Users List <>
>> Cc: 
>> Sent: Sunday, October 23, 2011 2:26 PM
>> Subject: Re: URI mapping
>> Pid wrote:
>> ...
>> The jsessionid cookie is set with the server
>>>  name of the Tomcat instance, rather than a domain with variable
>>>  subdomains*, unless you have configured it otherwise (Servlet 3.0 only).
>> Yes, but what /is/ this server name that this Tomcat will be using ?
>> I don't think that is as straightforward as it may look.
>> For example, what will Tomcat put in the cookie if this Tomcat is set up with a 
>> single <Host name="localhost">
>> but it runs on a host whose canonical name is 
>> "".
>> Does it use the hostname received in the "Host:" header of the 
>> request, even when this hostname does not match any of its <Host> tags ?
>> And what if there is no Host: header ?
> Andre,
> Exactly. Those were some of my questions as well. Right now though I'm setting up all
Apache named virtual hosts to Tomcat virtual hosts so that the names match.
> Apache HTTPD
> <VirtualHost *:80>
>   ServerName
>   ServerAlias somehost
> # more stuff
> </VirtualHost>
> Tomcat server.xml
> <Host name="ahost" appBase="some-absolute-path">
>   <Alias></Alias>
>   <!-- more stuff -->
> </Host>
> I don't map the default host (left at localhost). Based on what I've read so far, the
cookies should come back in a sane fashion. I may have to flip the Tomcat <Host> name
attribute and <Alias> element around to have a completely clean installation. This will
make CATALINA_BASE/conf/Catalina/<name> a bit ugly, but I can live with that.
> I should set this up with a test web application with cookies and watch the entire mess
with Firedebug.
By the way, if you are using mod_jk, you can use an alternative way to forward requests 
from Apache httpd to Tomcat.
Look at the bottom of this page :
the section entitled "Using SetHandler and Environment Variables".

Instead of using "JkMount /tomcat7/* tomcat7", you can use a Location section like

<Location /tomcat7>
   SetHandler jakarta-servlet
   SetEnv JK_WORKER_NAME=tomcat7
   SetEnvIf REQUEST_URI ..(regexp).. no-jk


to the same effect.
I personally prefer this kind of configuration over JkMount/JkUnmount, because I find that

it better "fits" within the Apache httpd configuration style, and it is also easier to 
figure out at what stage of the Apache cycle these directives take place.
And you can also add more "httpd things" in the <Location> section (e.g., authentication


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

View raw message