posted 14 years ago
Get the client's IP address using HttpServletRequest#getRemoteAddr() and use some geo location API to get the exact geo location based on the IP address. Google can find these API's, both freeware and payware.
That said, do not let your code depend too much on it. It's funny for statistics and some presentional features, but really not more than that. The IP address can easily be spoofed/hidden by the client.