tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: The best place for implementing context specific behavior?
Date Thu, 25 Jun 2009 20:20:40 GMT
Jonathan Mast wrote:
> Haha thanks, Andre, I'm not lost but it seems other people might be.
> I'm going to go ahead define separate hosts, although the <Alias> option
> mentioned might work, I don't know if it would preserve correctly the value
> returned by request.getLocalName() 
that's *wrong*, you should use request.getServerName().
getLocalName() will give you the name of the local "physical" machine, 
as per the interface your server's Tomcat is Listening on.
(in other words, you will always get the same answer).
getServerName will give you the hostname that the client used in his 
request, which is what you want.

which is what I'm using for determining
> the host specific content, but if someone knows better than say so.  The
> <Alias> element is kinda poorly documented on, it only has
> a paragraph. Seems like a holdover from httpd configs....

No it isn't. Using <Alias> or using another <Host> are two entirely 
different animals.
Both will achieve the same if all you want to do is a getServerName() at 
request time, but that's about all they have in common.

> On Thu, Jun 25, 2009 at 11:53 AM, André Warnier <> wrote:
>> Jonathan,
>> if by now you are a bit lost in the various options related to the hostname
>> and why, just say so. I have a practised step-by-step explanation available.
>> It's all pretty standard HTTP/name-based virtual hosts stuff, but it has
>> many people confused.
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> For additional commands, e-mail:

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

View raw message