Bug 37693 - APR Connector not up to Servlet 2.4 API spec for getLocalAddr() method
Summary: APR Connector not up to Servlet 2.4 API spec for getLocalAddr() method
Status: RESOLVED DUPLICATE of bug 37673
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Connector:HTTP (show other bugs)
Version: 5.5.12
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2005-11-29 16:58 UTC by Nate Rock
Modified: 2005-11-29 08:02 UTC (History)
0 users

Simple JSP demonstrating the bug (327 bytes, text/html)
2005-11-29 17:02 UTC, Nate Rock

Note You need to log in before you can comment on or make changes to this bug.
Description Nate Rock 2005-11-29 16:58:02 UTC
The servlet API spec reads as follows:

public java.lang.String getLocalAddr()The default behavior of this method is to 
return getLocalAddr() on the wrapped request object. 

Specified by:
getLocalAddr in interface ServletRequest
a String containing the IP address on which the request was received.

I tracked down the bug to the following code:


The action() method which is called with 


assings a hostname instead of an ip address to the localAddr variable 

1050: localAddr = addr.hostname;

which then sets it in the request object

1058: request.localAddr().setString(localAddr);
Comment 1 Remy Maucherat 2005-11-29 17:01:11 UTC

*** This bug has been marked as a duplicate of 37673 ***
Comment 2 Nate Rock 2005-11-29 17:02:00 UTC
Created attachment 17076 [details]
Simple JSP demonstrating the bug

This JSP demonstrates the bug clearly. It has both request.getLocalName() which
should return the local server's hostname. It also has request.getLocalAddr()
which returns the machines hostname, it should return the local server's IP
address. Open the .jsp in Tomcat 5.5.12 using the APR native connector.