dev@glassfish.java.net

Re: JSP request.getRemoteHost() returns IP address instead of host name

From: Jan Luehe <Jan.Luehe_at_Sun.COM>
Date: Wed, 23 Sep 2009 09:56:27 -0700

Hi Andy,

On 09/23/09 07:39, Andy Knight wrote:
> My research indicates that Tomcat, by default, has a configuration
> parameter called *enableLookups*. By default this is *false*. Under
> such circumstances an invocation of request.getRemoteHost() (when the
> host is the localhost) returns 127.0.0.1 (or 0:0:0:0:0:0:0:1%0 if
> you're running Mac OS X).
>
> If I change *enableLookups *to *true,* request.getRemoteHost() returns
> the string *localhost* as expected.
>
> When I deploy my web application to GlassFish and cause the same JSP
> code to run, I get the IP address as I would by default in Tomcat.
>
> How do I configure GlassFish to enable lookups in the way that Tomcat
> behaves?

use the following attribute:

- In GlassFish v2.x:
  http-service.http-protocol.dns-lookup-enabled=true

- In GlassFish v3:
  
network-config.protocols.protocol.http-listener-1.http.enable-dns-lookup=true


Jan

>
> <http://www.sun.com> Andy Knight
> Principal Engineer,
> Sun Microsystems, Inc.
> Java House, Guillemont Park, Minley Road,
> Camberley, Surrey GU17 9QG United Kingdom
> Home office: +44 1494 462438
> Mobile: +44 7775 583415
> Skype: aprknight
> Email: Andy.Knight_at_Sun.COM <mailto:Andy.Knight_at_Sun.COM>
> Blog: http://blogs.sun.com/andky
> <http://www.sun.com>
>
>