|
Well, we've run some tests, and it appears that
it *does* matter what the user enters for the host. Both addresses are
hosted by the same IIS server, and I've set multihoming in JRun for each of them
(if memory serves, it didn't work otherwise).
Our servlet checks to see if a ServletContext Attribute has
been set, and if not it gets the value and sets it in the ServletContext
("are you there? no? okay, here is what you need"). Whenever it
sets the Attribute, it also makes a log entry.
By calling the servlet with and without "www" we
were able to see that each time it set the Attribute.
We'll look at having our logging mechanism add the request.getServerName()
so that we can be certain.
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.
|