當前位置:編程學習大全網 - 網站源碼 - 怎麽獲取訪問壹個jsp頁面的mac地址

怎麽獲取訪問壹個jsp頁面的mac地址

不能直接獲取到客戶端的mac地址,可以通過IP地址獲取客戶端的mac

先獲取IP地址,ip =?request.getRemoteAddr();?

通過ip地址獲取mac

public String getMACAddress(String ip) { ?

String str = ""; ?

String macAddress = ""; ?

try { ?

Process p = Runtime.getRuntime().exec("nbtstat -A " + ip); ?

InputStreamReader ir = new InputStreamReader(p.getInputStream()); ?

LineNumberReader input = new LineNumberReader(ir); ?

while((str = input.readLine()) != null){

if (str.indexOf("MAC") > 1) {

//使用substring函數截出mac地址

//macAddress = str.substring(str.indexOf("MAC") + 9, str.length()); ?

break; ?

} ?

} ?

} catch (IOException e) { ?

e.printStackTrace(System.out); ?

} ?

return macAddress; ?

} ?

  • 上一篇:微信小程序裏的仙俠傳奇有網站嗎?
  • 下一篇:如何運用競價圖看全天走勢
  • copyright 2024編程學習大全網