打印IP 来源

<%
  String userAgent = request.getHeader("User-Agent");
  if (userAgent != null && userAgent.indexOf("http") == -1 && userAgent.toLowerCase().indexOf("spider") == -1) {
    String ip = request.getRemoteHost();
    IpUtil ipUtil = new IpUtil();
    String country = ipUtil.getCountry(ip);
    String area = ipUtil.getArea(ip);
    ip = ip + "(" + country + "-" + area + ")";
    System.out.println(ip + "," + request.getRequestURI() + "?" + request.getQueryString()  + ", [" + userAgent + "]" );
  }
%>

posted @ 2017-01-05 10:47  爱畔畔真是太好了  阅读(164)  评论(0编辑  收藏  举报