DZone
Java Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > Tomcat 5.5 and Tomcat 6 connector option enableLookups not defaulting to true

Tomcat 5.5 and Tomcat 6 connector option enableLookups not defaulting to true

Mick Knutson user avatar by
Mick Knutson
·
Feb. 10, 12 · Java Zone · Interview
Like (0)
Save
Tweet
5.71K Views

Join the DZone community and get the full member experience.

Join For Free

I have been working on an issue where HttpServletRequest.getHostName() always return the IP address, instead of the host name.

The Tomcat 5.5 and Tomcat 6 documentation states enableLookups is set to true by default.

enableLookups

Set to true if you want calls to request.getRemoteHost() to perform DNS lookups in order to return the actual host name of the remote client. Set to false to skip the DNS lookup and return the IP address in String form instead (thereby improving performance). By default, DNS lookups are enabled.

http://tomcat.apache.org/tomcat-5.5-doc/config/http.html

http://tomcat.apache.org/tomcat-6.0-doc/config/http.html

Interestingly enough, when we were on Tomcat 5.5 the reverse look-ups for HttpServletRequest.getHostName() worked fine. This seems to be an issue with the documentation for Tomcat 6. Luckily there is an easy solution.

Searching a little more, this seems to also be the same issue as reported in Tomcat 4:

https://issues.apache.org/bugzilla/show_bug.cgi?id=21621

But in the documentation for tomcat 4, the default is false so the assumption is correct.

Set to true if you want calls to request.getRemoteHost() to perform DNS lookups in order to return the actual host name of the remote client. Set to false to skip the DNS lookup and return the IP address in String form instead (thereby improving performance). By default, DNS lookups are disabled.

So the documentation for Tomcat 5+ changed and the functionality did not change.

Solution

To solve this issue, in server.xml I added enableLookups=”true” to the connector like this

<Connector enableLookups="true"
           port="8080"
           protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" />

Next steps will be to validate this on Tomcat 7.

 

From http://www.baselogic.com/blog/development/java-javaee-j2ee/tomcat-6-connector-option-enablelookups-defaulting-true/

Apache Tomcat Connector (mathematics)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • 3 Reasons Why You Should Centralize Developer Tools, Processes, and People
  • Classification of Neural Networks in TensorFlow
  • Building Reactive Java Applications with Spring Framework
  • Introduction to JWT (Also JWS, JWE, JWA, JWK)

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo