aspose file tools*
The moose likes Beginning Java and the fly likes Get the Remote machine IP address Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Get the Remote machine IP address" Watch "Get the Remote machine IP address" New topic
Author

Get the Remote machine IP address

sudhir pavan
Ranch Hand

Joined: Sep 01, 2011
Posts: 34
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

Joined: May 22, 2012
Posts: 871
    
    5
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

Joined: May 22, 2012
Posts: 871
    
    5
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

Joined: Jan 03, 2004
Posts: 6109
    
    6

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

Joined: Jul 08, 2003
Posts: 24187
    
  34

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
 
subject: Get the Remote machine IP address