dev@glassfish.java.net

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

From: Andy Knight <Andy.Knight_at_Sun.COM>
Date: Wed, 23 Sep 2009 15:39:53 +0100

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?

         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
Blog: http://blogs.sun.com/andky