日期:2014-05-18  浏览次数:20850 次

jsp 如何获得客户端的MAC地址??急~~~
jsp 如何获得客户端的MAC地址??急~~~,请各位大侠帮忙,谢谢~~~

------解决方案--------------------
用java好像是取不到的,因为Java是运行在服务器端的(除非你用Applet,但是Applet会受到很多限制)
我也不懂啊,关注中。。。

------解决方案--------------------
给你个实际的例子。改改就行啦!

别忘揭帖给分啊,^_^!

Java code
<%@ page contentType="text/html; charset=gbk"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Read MAC Test</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<SCRIPT language=JScript event="OnCompleted(hResult,pErrorObject, pAsyncContext)" for=mac>
 document.forms[0].txtMACAddr.value=unescape(MACAddr);
 document.forms[0].txtIPAddr.value=unescape(IPAddr);
 document.forms[0].txtDNSName.value=unescape(sDNSName);
  </SCRIPT>

<SCRIPT language=JScript event=OnObjectReady(objObject,objAsyncContext) for=mac>
   if(objObject.IPEnabled != null && objObject.IPEnabled != "undefined" && objObject.IPEnabled == true)
   {
    if(objObject.MACAddress != null && objObject.MACAddress != "undefined")
    MACAddr = objObject.MACAddress;
    alert("MACAddr"+MACAddr);
    if(objObject.IPEnabled && objObject.IPAddress(0) != null && objObject.IPAddress(0) != "undefined")
    IPAddr = objObject.IPAddress(0);
    if(objObject.DNSHostName != null && objObject.DNSHostName != "undefined")
    sDNSName = objObject.DNSHostName;
    }
  </SCRIPT>

<META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
<BODY>
<OBJECT id=locator classid=CLSID:76A64158-CB41-11D1-8B02-00600806D9B6 VIEWASTEXT></OBJECT>
<OBJECT id=mac classid=CLSID:75718C9A-F029-11d1-A1AC-00C04FB6C223></OBJECT>
<SCRIPT language=JScript>
   var service = locator.ConnectServer();
   var MACAddr ;
   var IPAddr ;
   var DomainAddr;
   var sDNSName;
   service.Security_.ImpersonationLevel=3;
   service.InstancesOfAsync(mac, 'Win32_NetworkAdapterConfiguration');
   </SCRIPT>

<FORM id=formfoo name=formbar action=readMACAction.do method=post>
    <INPUT value=00:05:5D:0E:A2:B1 name=txtMACAddr> 
    <INPUT value=192.168.0.102 name=txtIPAddr> 
    <INPUT value=typ name=txtDNSName> </FORM>
</BODY>
</HTML>