简体   繁体   English

如何在Web应用程序中查找客户端系统mac地址

[英]how to find client system mac address in web application

I need to find client MAC address who is accessing my website. 我需要找到正在访问我的网站的客户端MAC地址。 I have tried with java code. 我尝试使用Java代码。

try {

    Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
    while(networkInterfaces.hasMoreElements())
    {
        NetworkInterface network = networkInterfaces.nextElement();
        System.out.println("network : " + network);
        byte[] mac = network.getHardwareAddress();
        if(mac == null)
        {
            System.out.println("null mac");             
        }
        else
        {
            System.out.print("MAC address : ");

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < mac.length; i++)
            {
                sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));        
            }
             val = sb.toString();
            System.out.println(sb.toString());  
            break;
        }
    }
} catch (SocketException e){

    e.printStackTrace();

}

But it display as "network : name:eth0 (eth0) MAC address : EC-A8-6B-77-A9-AD" for all client system. 但是对于所有客户端系统,它都显示为“网络:名称:eth0(eth0)MAC地址:EC-A8-6B-77-A9-AD”

how can i do this? 我怎样才能做到这一点?

Server side Java code will never return the client's MAC address. 服务器端Java代码将永远不会返回客户端的MAC地址。

For that you would need a code running at the client. 为此,您需要在客户端运行的代码。 For example in IE you could get that with Javascript+ActiveX. 例如,在IE中,您可以使用Javascript + ActiveX来实现。 In other browsers (including IE) you could do that with a Java Applet, but security restraints might prevent the applet to access system information including the MAC address. 在其他浏览器(包括IE)中,您可以使用Java Applet来执行此操作,但是安全限制可能会阻止Applet访问包括MAC地址在内的系统信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何查找远程系统MAC地址 - How to Find Remote System MAC Address 找出与servlet Web应用程序中的MAC地址关联的IP地址 - Find out IP address associated with MAC Address in servlet web application 如何在 Restful web 服务中访问客户端的 MAC 地址 - How to access client's MAC address in Restful web services 如何在本地局域网上找到“关机”系统的MAC地址(可能吗?) - How to find the MAC address of a 'shutdown' system on local lan (is it possible?) 如何在Java Web应用程序中限制客户端IP地址 - How to restrict client IP address in Java Web Application 如何找到Java EE Web应用程序的系统要求 - How to find the system requirements for java ee web application 在Sun Java System Web服务器中保留客户端IP地址 - Preserving the Client IP Address in Sun Java System Web Server 如何获取到Jdeveloper 11.1.1.7中构建的Web服务应用程序的主叫客户端的IP地址? - How to get IP address of the calling client to the web-service application built in Jdeveloper 11.1.1.7? 如何在Java中的多客户端/服务器应用程序中查找所有已连接客户端的IP地址? - how to find ip address of all connected clients in multi-client/server application in java? 如何获取Web服务客户端的IP地址? - How to get IP address of a web service client?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM