开发者

Get IP, ISP and GeoLocation of a webpage visitor

Is there any way to get the ISP and GeoLocation for a user that access 开发者_如何学JAVAa website in Java?

Getting the IP is easy. It's request.getRemoteAddr(). Any hints on getting the ISP and location? Are there any API's or libraries available? I'm guessing that you have to map all the IPs to ISPs. Any ideas?


There is no ready solution in Java. In general there is only one method to do it - you should use whois protocol to access data about host's ip from Regional Internet Register (RIR), for example from http://www.db.ripe.net/whois. Other solutions in the Internet will more or less depend on RIRs + some algorithm to process data.

There is a possibility to use telnet to connect to RIPE or copy a snapshot of database onto your server.

The only problem is that the output from whois is not very convenient to process. Everything depends on your application and required accuracy.


Try with MaxMind GeoIp Java API. The more complete and accurate IP database is commercial, but they have a free Country and City "light" database.

http://www.maxmind.com/app/java

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜