• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Getting IP and location of a client

 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,
How can I get the location and IP address from a client's request. Any ideas?
 
Marshal
Posts: 7266
1397
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Fawad Ali
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Saloon Keeper
Posts: 7632
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Search for "maxmind geoip java".
 
Ranch Hand
Posts: 59
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
check this page

http://stackoverflow.com/questions/2257170/how-to-get-city-name-based-on-ip-address-in-java
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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/.
 
You get good luck from rubbing the belly of a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic