I want to develope a servlet that can know the IP of the client and determin to which country he is belong.
I am thinking to specify the proxy name (if possible) , so if it is ends with uk so the user from england and so on....
any ideas ...
The second part is tricky to say the least.
There is no real geographic split in IP addresses anymore. Though in theory blocks are assigned to regional entities this doesn't suffice for your purpose as there are super-regional customers to those entities.
For example, AOL may request a range of IP addresses from the US pool and assign those to German customers. If you used the pool from which they are drawn as a basis you'd class that German as an American.
The pools are also not fine-grained enough for your purpose. All of Europe shares a single agency for handing out blocks for example.
More information on IP assignments: http://www.ripe.net/ripencc/about/regional/
You could try a whois lookup on the number and try to determine where it is assigned to.
But that still would not necessarilly resolve scenarios where an IP address is assigned to a company in one country but used by a computer located in another.
Originally posted by Paul Sturrock:
There is an accept-language header which forms part of HTTP. From this you can get the prefered Locale of the client, presuming the request includes this header. Of course there is not guarentee the Locale a user sets their machine to maps to the actualy country they are in.
none at all indeed.
For example I'm definitely not in the USA or UK but I have my preferences set to UK English first, US English second and Dutch third.
That would make
I think I send German (DE_de, DE_at) as well.
Most people never change those settings at all, and unless they have a localised OS and browser for not just their language but country incorrect data will be returned.
If the resulting TLD is something like ".uk" or ".de", then you're in luck. Otherwise, you'll have to fall back on some other method (like parsing the language info in the HTTP header).
Hope that helps .. PSM