dev@glassfish.java.net

Re: Obtaining the hostname from Listeners

From: Tom Mueller <tom.mueller_at_oracle.com>
Date: Mon, 21 Mar 2011 10:13:02 -0500

Generally, there isn't a single hostname for a listener, especially when
the listener is listening on 0.0.0.0. In this case, the listener is
listening to all IP addresses. Typically this will be the primary IP
address for the system, plus 127.0.0.1. If on a multihomed server, it
will be listening on other IP address too. Each IP address may have
several names, depending on what is in DNS or the /etc/hosts file.

The com.sun.enterprise.util.net.NetUtils class (common/common-util
module) has some methods that might be useful in solving this problem,
or at least it has code that deals with multiple addresses and names.
Maybe a new method could be added there for solving this problem.

Tom

On 3/21/2011 7:03 AM, Nithya Subramanian wrote:
> Hi,
>
> In the context of fixing GlassFish Issue 16209, we are looking for a
> way to obtain the hostname of the GF instance from the listener in
> which the request was received (in order to compare it with the Host
> header of the request).
>
> We tried to get the Network listeners , loop through them and get the
> serverName /address of the individual ones, however the serverName is
> set to null and the address is set to 0.0.0.0 by default.
>
> Is there a way in which we could obtain the hostname of the GFinstance
> through the listeners ?
>
> Thanks
> Nithya
>
>
>
>