하은양 믿음군 효실맘 호홍홍집s

접속 IP 구하기 본문

가벼운 배움/jsp

접속 IP 구하기

호홍홍집 2016. 12. 26. 14:44

    접속자 IP를 구하는 방법 ... 까먹지 말자

    String sREMOTE_IP = request.getHeader("X-Forwarded-For");
    if (sREMOTE_IP == null || sREMOTE_IP.length() == 0 || "unknown".equalsIgnoreCase(sREMOTE_IP)) {
        sREMOTE_IP = request.getHeader("Proxy-Client-IP");
    }
    if (sREMOTE_IP == null || sREMOTE_IP.length() == 0 || "unknown".equalsIgnoreCase(sREMOTE_IP)) {
        sREMOTE_IP = request.getHeader("WL-Proxy-Client-IP");
    }
    if (sREMOTE_IP == null || sREMOTE_IP.length() == 0 || "unknown".equalsIgnoreCase(sREMOTE_IP)) {
        sREMOTE_IP = request.getHeader("HTTP_CLIENT_IP");
    }
    if (sREMOTE_IP == null || sREMOTE_IP.length() == 0 || "unknown".equalsIgnoreCase(sREMOTE_IP)) {
        sREMOTE_IP = request.getHeader("HTTP_X_FORWARDED_FOR");
    }
    if (sREMOTE_IP == null || sREMOTE_IP.length() == 0 || "unknown".equalsIgnoreCase(sREMOTE_IP)) {
        sREMOTE_IP = request.getHeader("REMOTE_ADDR");
    }
    if (sREMOTE_IP == null || sREMOTE_IP.length() == 0 || "unknown".equalsIgnoreCase(sREMOTE_IP)) {
        sREMOTE_IP = request.getRemoteAddr();
    }