I am having many tomcat servers, which run the same JSP application and load balancer. I like to know from which IP address is client request. I am using this code:
String ipAddress = request.getHeader("X-FORWARDED-FOR");
if (ipAddress == null) {
ipAddress = request.getRemoteAddr();
}
The code request.getHeader("X-FORWARDED-FOR")
is always null and request.getRemoteAddr()
is always returning the same IP address from diffrent client machines. What is the problem?