Jerry Jacob's Blog

Client IP Address in Java

Posted in Java/ J2EE by jerlinworld on May 6, 2013

//IP address of request's HTTP header ""X-FORWARDED-FOR"

String ipAdr = request.getHeader("X-FORWARDED-FOR");

if (ipAdr == null) {

ipAdr = request.getRemoteAddr();

}

Opensource RESTful API for searching the geolocation of IP Addresses and hostnames.
https://github.com/fiorix/freegeoip (http://freegeoip.net/)

Advertisements
Tagged with: