The first part (retrieving the IP address) is easy, just call "getRemoteAddr()" on the request.
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.