String IP = httpRequest.getHeader("x-forworded-for");
if (IP != null && IP.length() != 0) {
while ((IP != null) && (IP.equals("unknow"))) {
IP = httpRequest.getHeader("x-forworded-for");
}
}
if (IP == null || IP.length() == 0) {
IP = httpRequest.getHeader("Proxy-Client-IP");
}
if (IP == null || IP.length() == 0) {
IP = httpRequest.getHeader("WL-Proxy-Client-IP");
}
if (IP == null || IP.length() == 0) {
IP = httpRequest.getRemoteAddr();
}
// 得到访问者所在网段
String subIP = IP.substring(0, IP.lastIndexOf("."));
System.out.println("真实的IP地址:" + IP+"网段是:"+subIP);
posted on 2008-04-03 09:31
Crying 阅读(283)
评论(0) 编辑 收藏 所属分类:
Jsp+Struts