I saw this problem in serveral different installations... using mod_jk as well as mod_proxy... Currently I am analysing an installation with an apache 1.3.41 using mod_jk (1.2.23). request.getLocalAddr() returns null... request.getLocalPort() returns 447 447 is the used apache https port. The ServletSpec is not very concrete how to answer this... but returning null is a bug definitly... Solution Approaches 1.) Idealy getLocalAddr() should return the IP Address of the network interface used to reach apache... 2.) From my point of view it would be also ok, when returning IP and Port(!!!!) over which the AJP connector have been reached... 3.) If both is not possible it would be great to have an additional configuration setting for the AJP connector.. eg request.LocalAddr and request.LocalPort... This shuld be easy to implement.
The AJP protocol only passes the web server host name and port. It does not pass the IP address. Therefore, getLocalName() will return whatever is passed via AJP but getLocalAddr() will always return null. Whilst getLocalAddr() could be modified to return the IP address Tomcat is listening on for AJP connections, I don't like the inconsistency that would generate when compared to getLocalName() and getLocalPort().