William Brogden wrote:I have my Tomcat configured to serve 6 different host addresses using <Host entries in server.xml - naturally all 6 have been registered with DNS entries pointing to the same IP - Tomcat looks at the URL and decides which set of webapp files to use from the appBase attribute in the Host entry.
Bill
>
Well..... Actually not quite like that, I think.
Each Host entry specifies a Host Name - or more precisely, Domain Name. When a TCP IP request comes into port 8080, Tomcat looks at the URL and pattern-matches it against the list of Hosts. There's a default host if it doesn't match. Once the Host has been determined, then the Contexts defined for that host are pattern-matched against the URL to determine the webapp context. That determines which of the deployed webapps receives the request. The further routing of the incoming URL request is then determined by rummaging around in the webapp's web.xml.
And, of course, the app-local part of the classpath and the other resource paths for that Context are defined relative to the appBase in the Context.
In the case of the server box I mentioned earlier, some of the hosts I named had individual IP addresses of their own various reasons, so the IP address isn't "naturally" always the same. But placing a network interface card into promiscuous mode so that it may answer to multiple IP addresses does carry a performance penalty, so natural or not, it's generally better.
Incidentally, one of the reasons for the multiple IP addresses is that back when I set all this up, there was still some HTTP 1.0 traffic kicking around, and Virtual Hosts don't like sharing the same IP address in HTTP 1.0. You need at least HTTP 1.1 for that.