It depends on whether of not the 2 hostnames serviced by the same server and if they are considered different virtual hosts or not.  If they are considered the same virtual host, then you should get the same context. 
 
I expect that most servlet engines would implement a mapping mechanism of hostname-to-context that allows multiple hostnames to be mapped to the same context.  This is especially necessary when considering that the HTTP 'host' header will sometimes contain fully qualified host names, and other times it will contain shortened names because of differences in the domain name that the client may be accessing the page from.  The names that the client accesses the website using maybe different, but from a site perspective, they are the same host.  In this case, they should access the same ServletContext.
 
For example,  if my client is in the domain 'bar.com', then I can access the servlet in server foo.bar.com using the URL http://foo.bar.com/servlet/snoop or http://foo/servlet/snoop .This means that the server needs to be able to maps requests for host foo or foo.bar.com to the same ServletContext.  The most obvious was to accomplish this is by abstracting the ServletContext to be named, and then mapping a set of host names to that context.
 
Sample config:
ServletContext.foo.hosts=foo.bar.com foo
 
-spike
----
Spike Washburn
Allaire Corp.
 
 
 -----Original Message-----
From: Lance Lavandowska [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 25, 1999 11:15 AM
To: [EMAIL PROTECTED]
Subject: ServletContext and Domains

We've been experiencing some odd behaviour with ServletContext Attributes (reloading when they shouldn't).  In reading the spec (2.1) I see
"In a server that supports the concept of multiple hosts (and even virtual hosts), the context must be at least as unique as the host. "
 
Does this mean that if I call a servlet at http://www.domain.com/servlet/runMe that it has a different context than calling it at http://domain.com/servlet/runMe ?  If this is true, than the ServletContext attribute (say "timeFirstHit") would be different for the two urls above since they are in two different ServletContexts.  Right?  Or should they have the same ServletContext and thus the same value?
 
I appreciate any clarification anyone can add to this issue.

Lance Lavandowska
Software Engineer
http://www.AgDomain.Com

Reply via email to