Difference between request.getRemoteAddr() and request.getLocalAddr()?
Ren Sha
Greenhorn
Joined: Mar 08, 2012
Posts: 9
posted
0
Hi friends,
I need to get the client IP so i was using getRemoteAddr() then one of my friend told me i need to use getLocalAddr() instead of this(the first one was working fine).
When i read the description i'm bit confused about getLocalAddr(), from the description i understand it'll returns IP of the interface on which the request was received.
It won't be client IP, right? Is it the server IP?
Please help me
Christian Ludt
Greenhorn
Joined: Apr 07, 2009
Posts: 11
posted
0
Hi Ren,
getRemoteAddr() is what you need to use:
Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.
getLocalAddr() returns the IP of the server the application is running on.
Just be careful, the remote IP address may or may not be the address of the client. And when the client is using DHCP (which most folks do) then the IP address can and will change during the session.