Forums Register Login

IP address retrieval

+Pie Number of slices to send: Send
Hello
I'm writing a servlet which will be put on our server.
A client can make a request for this servlet.I would like to retrieve the IP address of the client machine(which could be behind a firewall).What code should be put in the servlet to make this happen.
Thanks in advance
Sunil
+Pie Number of slices to send: Send
It's one of the http headers - REMOTE_ADDR. However, it's not reliable for general use - it can be spoofed, translated, or otherwise removed or tampered with. Check the servlets forum and you'll see a fairly detailed discussion that went on about this a week or so back.
+Pie Number of slices to send: Send
Hi,
I used HttpServletRequest.getRemoteHost() and it worked fine (LAN). However, I'm not sure if it can achieve the machine's ip behind firewall.
Please check it
+Pie Number of slices to send: Send
"Jolly Jumper",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp .
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in again with a new name which meets the requirements.
Thanks.
Dave.
+Pie Number of slices to send: Send
It's not that the getRemoteHost() necessarily fails - just that due to previously-mentioned IP-mangling processes, IPs are not reliable identifiers.
What do you have to say for yourself? Hmmm? Anything? And you call yourself a tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1247 times.
Similar Threads
IP address retrieval
Get the website name in the sevlet
Track client request
Difference between request.getRemoteAddr() and request.getLocalAddr()?
Getting IP and location of a client
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 08:17:00.