0
我正在開發一個安全投票系統的應用程序。我需要將特定機器的MAC地址設置爲「投票機」。我如何獲得客戶機的MAC地址?我如何獲得jsp客戶端機器的MAC地址
我正在開發一個安全投票系統的應用程序。我需要將特定機器的MAC地址設置爲「投票機」。我如何獲得客戶機的MAC地址?我如何獲得jsp客戶端機器的MAC地址
//InetAddress address = InetAddress.getLocalHost();
InetAddress address = InetAddress.getByName("192.168.46.53");
/*
* Get NetworkInterface for the current host and then read the
* hardware address.
*/
NetworkInterface ni = NetworkInterface.getByInetAddress(address);
if (ni != null) {
byte[] mac = ni.getHardwareAddress();
if (mac != null) {
/*
* Extract each array of mac address and convert it to hexa with the
* following format 08-00-27-DC-4A-9E.
*/
for (int i = 0; i < mac.length; i++) {
System.out.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : "");
}
} else {
// Address doesn't exist or is not accessible.
}
} else {
// Network Interface for the specified address is not found.
}
我怎樣才能使用JSP獲取客戶端的MAC地址? – 2011-05-09 08:41:23
在後面的代碼中使用這段代碼.... – 2011-05-09 08:43:07
如何做到這一點?這裏是新的... – 2011-05-09 08:45:41