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