users@servlet-spec.java.net

[servlet-spec users] [jsr340-experts] Re: New API ServletContext#addVirtualHostName

From: Rémy Maucherat <rmaucher_at_redhat.com>
Date: Tue, 26 Feb 2013 22:55:31 +0100

On 02/26/2013 10:19 PM, Greg Wilkins wrote:
> Remy,
>
> My understanding of this method is that it is on the servlet context,
> thus it is available when there is no request (eg in the init method),
> hence it is more than just syntax sugar over getHeader("Host").
Ah yes, very good point. My mistake.
>
> I don't actually see a huge need for either the single valued method
> or the multivalued one, as any usage of them for prepreparing URIs
> etc. risks being wrong if the client uses a name mapping unknown to
> the server. Ie the host header should always be used for generating
> URIs in the name space of the client.
>
> But the single valued one may be useful for logging or selecting a DB
> partition or otherwise parameterizing configuration. I can't think of
> any really good reasons for the multivalued one, but then I don't see
> any reason to hide this information. Containers will have a list of
> virtual names aliases (or patterns?) so why not expose this in a
> standard way.
>
> If we go with only the single valued one, then the javadoc should note
> that multiple virtual host names may be configured for the context and
> the method returns the preferred one (or at least the first).
Yes, it's not necessary to hide the aliases, but it could also be useful
to distinguish the real name. The two uses mentioned (logging,
parametrization) would need it. If a collection is the returned value,
the first element could be specified as the main name of the vhost, and
maybe use a List ?

Rémy