javaWeb获取IP和MAC地址
JAVA WEB获取访问(请求)用户电脑的IP和MAC地址的方法,具体如下两个方法:
//根据HttpServletRequest获取ip
private String getIpAddr(HttpServletRequest request) {     
        String ip = Header("x-forwarded-for"); 
        //处理代理
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 
无法获取ip地址            ip = Header("Proxy-Client-IP"); 
        } 
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 
撷字怎么读            ip = Header("WL-Proxy-Client-IP");  会计初级职称准考证打印
        } 
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 
            ip = Header("HTTP_CLIENT_IP"); 
        } 
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 
            ip = Header("HTTP_X_FORWARDED_FOR"); 
        } 
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) { 
            ip = RemoteAddr(); 
        } 
        return ip;     
    }关于蛇的成语
    //根据IP 获取到MAC地址,前提是能ping通,并且要关闭防火墙
    private String getMacByIp(String ip){
        String macAddress = "";
        try{
            Process p = Runtime().exec("nbtstat -A " + ip);
            InputStreamReader ir = new InputStream()); 
            LineNumberReader input = new LineNumberReader(ir);
描写雪景的成语
            String str = "";
            while ((adLine())!=null) {
                str = UpperCase(); 
                if (str.indexOf("MAC ") > 1) { 
                    int start=str.indexOf("=");
                    macAddress = str.substring(start+1).trim();
                    break; 
                }
            }
冯子存是我国的什么演奏家        }catch(Exception e){
            e.printStackTrace();
        }
        return macAddress;
    }

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。