Hello,
I am trying to retrieve the client IP address accessing the web
services. Because Apache is our proxy for all requests, when I try to
retrieve the client IP I always get the localhost IP: 127.0.0.1
The following code returns the localhost IP:
MessageContext msgContext = MessageContext.getCurrentContext();
if(msgContext != null) {
return msgContext.getProperty(Constants.MC_REMOTE_ADDR).toString();
}
return "Unknown";
From a servlet, obtaining the client IP address can be achieved using
this code.
String ipAddress = request.getHeader("x-forwarded-for");
if (ipAddress == null) {
ipAddress = request.getHeader("X_FORWARDED_FOR");
if (ipAddress == null){
ipAddress = request.getRemoteAddr();
}
}
return IPaddress ;
Any help is greatly appreciated.
Thank you very much
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]