This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting ip address

 
Bernard Sigmund Gustav
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 127.0.0.0 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

thanks
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic