I'm trying to develop a webapp that can extract the IP address, the webbrowser's description and the country of the enduser's request.
But I can't find how to deal that. How can I do this, please ?
I'm trying to develop a webapp that can extract the IP address, the webbrowser's description and the country of the enduser's request.
But I can't find how to deal that. How can I do this, please ?
There is quite a bit of info on this available. Much depends on what you are running on the server: How to get client's IP address using javascript only?, Getting a user country name from originating IP address with Ruby on Rails
This information is provided by
javax.servlet.HttpServletRequest
:request.getRemoteAddr()
request.getHeader("user-agent")
There is normally no country information, so you have to use a geolocation service together with the IP address.
For example http://freegeoip.net: Use an URL like
http://freegeoip.net/xml/www.stackoverflow.com
Other formats (CSV, JSON) are possible, it's described on their home page.
Possibly helpful:
request.getHeader("accept-language")
: Contains a list of languages (like "en", "de", "fr", ...)Note: There is always the IP address, but request headers are optional.