• Post Reply Bookmark Topic Watch Topic
  • New Topic

client info using java  RSS feed

 
Alex George
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the best way to get client information such as user time zone, ip address...etc from the browser or request?
Thank you very much.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HTTP doesn't transfer much client-side information. (Http)ServletRequest has a few methods like getRemoteAddr and getRemoteHost that may be of interest.

An option might be to collect some more information on the client via JavaScript (like the timezone via new Date().getTimezoneOffset()), and then transfer them AJAX-like with an XmlHttpRequest call to the server.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See if This helps. I know I've visited sites that try to show ads (ok, desperate women) based on my location. I guess there must be an IP to region lookup somewhere. Sometimes they think I'm way across country, so it can't be very reliable.

Ok,couldn't resist snooping. Found this:
[code<form method="POST" action="http://www.geobytes.com/IpLocator.htm?GetLocation">
<input type="hidden" name="cid" value="0">
<input type="hidden" name="c" value="0">
<input type="hidden" name="Template" value="iplocator.htm">
<h3>IP Address to locate:<input type="text" name="ipaddress" size="15" value="xx.xx.xx.xx"> <input type="submit" value="Submit">
</form>
[/code]
I'll let you judge how well it works.
[ November 29, 2007: Message edited by: Stan James ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!