I am developing a web application using JSP, Servlets (Container: Glassfish) in which I need to get clients IP Address.
I am getting the clients IP address, because I want to give access to some pages (like Customer maintenance forms) only on computers withing the office, I want to restrict access to those pages outside office.
Following is my code so far:
way1
String ipAddress =  request.getRemoteAddr();
System.out.println("IP Address: "+ipAddress);
way2
String ipAddress=null;
String getWay = request.getHeader("VIA");   // Gateway
ipAddress = request.getHeader("X-FORWARDED-FOR");   // proxy
if(ipAddress==null)
{
    ipAddress = request.getRemoteAddr();
}
System.out.println("IP Address: "+ipAddress);
Above code gives me different IP Address each time when I restart my computer (Shutdown->Start or Restart).
I am getting IP6 like:
fe80:0:0:0:20ca:1776:f5ff:ff15%13
Let me know what is wrong with this code?
 
     
     
     
     
     
     
     
     
    