I am using the following code to get the IP address form a client.
public String getIp(@Context HttpServletRequest requestContext, @Context SecurityContext context) {
HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
String ipAddress = request.getHeader("X-FORWARDED-FOR");
if (ipAddress == null) {
ipAddress = request.getRemoteAddr();
}
return ipAddress;
}
However, when it executes, it returns 0:0:0:0:0:0:0:1
. It is running on my local pc, and I would expect it to return good ol 127.0.0.1
. Any ideas why not?