File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get the Remote machine IP address

 
sudhir pavan
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I need to get the remote IP address of the machine using my web application .
I need to get this address without using servlet concept.
can you help me out.

If the remote client uses proxy server, then how to get the real IP address.

Thanks.
 
Ivan Jozsef Balazs
Rancher
Posts: 972
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to get this address without using servlet concept.


Your question is rather vague , so I do not know whether it helps you, that javax.servlet.ServletRequest has the methods


 
Ivan Jozsef Balazs
Rancher
Posts: 972
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But of course if the client sits behind a firewall, you won't learn its IP address.

Also if there is clustering or a firewall etc. before your servlet, then the "raw" IP-address won't help you either.
In this case, if we talk about HTTP requests, they can get added a header with the original IP address.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And of course the actual IP address of the host on the other end is generally meaningless, since in many (most?) cases it will be a private IP address. I could be talking to 50 different hosts at once, spread all over the globe, and all with an IP address of 192.168.1.2.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff Verdegan wrote:And of course the actual IP address of the host on the other end is generally meaningless, since in many (most?) cases it will be a private IP address. I could be talking to 50 different hosts at once, spread all over the globe, and all with an IP address of 192.168.1.2.


This is correct, but I wanted to make it clear that ServletRequest.getRemoteAddr() will return the public address of the firewall or NAT box; it won't ever return such a private address.

sudhir pavan, as you can see, this is neither possible nor meaningful: even if you could get that address -- which you generally could not, not without client-side code like a signed applet, anyway -- it would often be worthless to you.

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic