aspose file tools*
The moose likes Servlets and the fly likes Getting IP and location of a client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Getting IP and location of a client" Watch "Getting IP and location of a client" New topic
Author

Getting IP and location of a client

Fawad Ali
Ranch Hand

Joined: Dec 28, 2009
Posts: 112
Hi guys,
How can I get the location and IP address from a client's request. Any ideas?


Regards, Fawad Ali.
Software Engineer, Stafona Inc. - My Blog
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 2885
    
  13

Have a look at the docs for getRemoteAddr() method. Note that it yields the IP address of the last proxy - which may probably not be the original client.


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
My Home Page -- Twitter Profile -- JavaRanch FAQ -- How to Ask a Question
Fawad Ali
Ranch Hand

Joined: Dec 28, 2009
Posts: 112
Devaka:
I am replying so late to the thread but my concern here is that how do sites like google or yahoo finds the location of the client. Do they get the IP address and then search through some kind of database table or what? I have to show a client's location (country and City) on a web page but I do not know what will be the best way(approach) to do it.

Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Search for "maxmind geoip java".
Ravi Majety
Ranch Hand

Joined: Feb 26, 2009
Posts: 59

check this page

http://stackoverflow.com/questions/2257170/how-to-get-city-name-based-on-ip-address-in-java
Daniel Val
Ranch Hand

Joined: Jan 09, 2012
Posts: 41
Fawad Ali wrote:Devaka:
I am replying so late to the thread but my concern here is that how do sites like google or yahoo finds the location of the client. Do they get the IP address and then search through some kind of database table or what? I have to show a client's location (country and City) on a web page but I do not know what will be the best way(approach) to do it.



Hi,

When google goes to that page, the page will show the location of the google spider (web crawler) , not the location of the other clients. So getRemoteAddr should be fine.

D.
nila ragunanthan
Greenhorn

Joined: Sep 07, 2012
Posts: 1
Fawad Ali wrote:Hi guys,
How can I get the location and IP address from a client's request. Any ideas?


Hi,
You can't find the Ip-address of your clients.but if you have Ip address You can find the Location,ISP provider,Latitude,Longitude of that Ip in online sites like http://www.ip-details.com/.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting IP and location of a client
 
Similar Threads
javax.naming.CommunicationException: Destination unreachable
can we detect location if GPS is not accesible
How to find country name and language in java
get location of client?
[B&S] - Need help determining a plan of action with options window