File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes getting ip address Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "getting ip address" Watch "getting ip address" New topic

getting ip address

Bernard Sigmund Gustav
Ranch Hand

Joined: Dec 20, 2005
Posts: 170
Hello everyone.

How can I access a computer's ip address or computer name in java or jsp?

I tried getRemoteAddr() but it returns the loopback address and getRemoteHost also returns localhost/or the server name.

i want to get the ip address of the pc trying to access the server and not the address of the server itself

Nathan Pruett

Joined: Oct 18, 2000
Posts: 4121

getRemoteAddr() and getRemoteHost() really should work - to an extent... These calls will return the IP/host of the client, or the last proxy before they hit the web page. Is it possible that there's something that could act as a "proxy" on your server before the client hits the web page?

Write once, run anywhere, because there's nowhere to hide! - /. A.C.
I agree. Here's the link:
subject: getting ip address
It's not a secret anymore!