Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Client Location

 
Prabhat Jha
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In my application the server needs the location of client.
For e.g if a client say "A" is accessing the website from say a place "B" then the server needs this information.
This location should be the exact location and not the country from where the client is accessing.

Kindly let me know how to achieve this.
 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the HTTP request header - "Accept-Language"
 
Prabhat Jha
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need the location for e.g if the user is in say "Detroit" then i need the place of client as "Detroit" when the user moves to "Troy" i need the place of client as "Troy".

Thanks
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think you'll be able to do this with much reliability.

The best you could do is use their IP (request.getRemoteAddr()) to try to look up the location. There are/were some public databases that attempted to keep track of IP numbers and their latitude and longitude but I don't think there is a formal system for keeping them up to date though.

Also, getRemoteAddr isn't necessarily going to get you the actual IP of the user. They may be running though a proxy or VPN in another city, state, or country altogether.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65116
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll have to ask them.
 
Prabhat Jha
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does this mean this is not possible ?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65116
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not possible.
 
Prabhat Jha
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A big Thank You to all for there response

After doing googling for quite some time it seems like in order to do this i may have to integrate my application with some GPS Providers.

Is anyone having experience in integrating Web Application with GPS?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think you're going to find very many desktop computers with GPS receivers in them.

In any case the work for this wouldn't happen on the web server.
It would happen in the client.
Lookup JSR-179, the API that cell phones and other handheld devices expose to Java developers.

Bear's last post in this thread is probably your best answer.
[ March 12, 2008: Message edited by: Ben Souther ]
 
Prabhat Jha
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You for helping me out and explaining things so nicely
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic