JSP如何取得客户端网卡的MAC地址?

eyoexply 2004-07-18 10:51:43
可以实现吗?
...全文
509 26 打赏 收藏 转发到动态 举报
写回复
用AI写文章
26 条回复
切换为时间正序
请发表友善的回复…
发表回复
cqpower 2004-10-29
  • 打赏
  • 举报
回复
这个javabean只能用于windows2000操作系统哈。
原理就是截取DOS的ping命令的输出而已

代码如下:
package net.cqpower.util;

import java.io.*;
/**
* <p>Title: puwei CRM</p>
* <p>Description: Chong Qing puwei CRM</p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: puwei</p>
* @author ZhangPu
* @version 1.0
*/

public class MAC2000
{
/**
* Description : get the MAC of localhost.
* @return
*/
public static String getMAC()
{
String strMAC = "";
try
{
java.lang.Process proc = Runtime.getRuntime().exec("ipconfig /all");
InputStream istr = proc.getInputStream();
byte[] data = new byte[1024];
istr.read(data);
String netdata = new String(data);
strMAC = procAll(netdata);
}catch(IOException e)
{
System.out.println("error="+e);
return null;
}
return strMAC;
}

public static String procAll(String str)
{
return procStringEnd(procFirstMac(procAddress(str)));
}
public static String procAddress(String str)
{
int indexof = str.indexOf("Physical Address");
if(indexof>0)
return str.substring(indexof,str.length());
return str;
}
public static String procFirstMac(String str)
{
int indexof = str.indexOf(":");
if(indexof>0)
return str.substring(indexof+1,str.length()).trim();
return str;
}
public static String procStringEnd(String str)
{
int indexof = str.indexOf("\r");
if(indexof>0)
return str.substring(0,indexof).trim();
return str;
}

/**
* Discription : test inside of class.
* @param arg
*/
public static void main(String[] arg)
{
String strMAC = MAC2000.getMAC();

System.out.println("Your Mac Address=" + strMAC);
}

}
luckydog903 2004-10-29
  • 打赏
  • 举报
回复
<%@ Language="VBScript" %>
<% Option Explicit %>
<html>
<head>
<title>查看网络设置</title>
</head>
<body bgcolor="#FFFFFF">
<%
dim strHost
dim oShell,oFS,oTF
dim i,Data,tempData
strHost="ipconfig"
Set oShell = Server.CreateObject("Wscript.Shell")
oShell.Run "%ComSpec% /c ipconfig > C:\" & strHost & ".txt", 0, True
Set oFS = Server.CreateObject("Scripting.FileSystemObject")
Set oTF = oFS.OpenTextFile("C:\" & strHost & ".txt")
Do While Not oTF.AtEndOfStream
Data = Trim(oTF.Readline)
If i > 2 Then
tempData = tempData & Data & "<BR>"
End If
i = (i + 1)
Loop
response.write tempData
oTF.Close
oFS.DeleteFile "C:\" & strHost & ".txt"
Set oFS = Nothing
%>
</font>
</body>
</html>


「已注销」 2004-10-29
  • 打赏
  • 举报
回复
me,too!
Soli 2004-10-29
  • 打赏
  • 举报
回复
学习之~~~~~~~~~~
takecare 2004-10-29
  • 打赏
  • 举报
回复
打电话问问是什么mac就行了。
figoren 2004-10-29
  • 打赏
  • 举报
回复
jni+rmi+jsp 可以实现
sean_gao 2004-10-28
  • 打赏
  • 举报
回复
别抱任何幻想了,纯JSP绝对做不到。
鱼鱼 2004-10-28
  • 打赏
  • 举报
回复
再说了Jsp是服务器端执行的程序,request里又没有包含客户端的Mac地址。要是做的话我认为需要客户端的JavaScript和服务器端的JSP配合才可以实现
鱼鱼 2004-10-28
  • 打赏
  • 举报
回复
虽然三楼没有实现你说的要求,但我觉得他的那种操作方法还是又用的,刚好我要用到类似的东西
zairwolfi 2004-10-28
  • 打赏
  • 举报
回复
,+***+,
,*********, , ,@@,
.****+++****,*: ,WW.
,***:.,,,.+****+ ,WW.
***., ,:***+ ,WW.
.**: ****+ ,WW.
+*+, ,.+++. :@@*, +@@:,WW.*@*.#@:
**: ,,,,,WWWWWW: ,WWWWWWWW.#WWWWWWW,+++,
,**: @WW@*WW. WWW**WWWW.#WWW#*WW* ::
,**: WWW*,.., #WW:,,.@WW.#WW+.,+WW,. .
+*+, .WWWW+, WW+, .WW.#W@. .WW,+#
.**, ,:WWWWW:,WW: ,WW.#W@, .WW,@@,
,***, ., ,.:#WWW.WW*, .WW.#W#, .WW.#+,
.***, +**, +,,,WWW:+WW. WWW.#W#, .WW. ,
,.*****+*****. WWWWWWW.,WWWWWWWWW.#W#, .WW,**,
,.********+., :WWWWWW+, .@WWWW@WW.#W#, .WW,**
,.+++++:, ,.:++:., ,:++:.++..++, ,++,,,
,,,,, ,,,, ,,, ,,,,,, ,,
用http://bbs.soulsky.net/pub/ascii/做的。
epson1980 2004-10-27
  • 打赏
  • 举报
回复
mark
idoo 2004-10-27
  • 打赏
  • 举报
回复
我也想知道。。。
debug148 2004-10-27
  • 打赏
  • 举报
回复
混个脸熟!
eureka0891 2004-08-26
  • 打赏
  • 举报
回复
mark,学习一下子!
noproblem12 2004-08-26
  • 打赏
  • 举报
回复
关注
cqusgx 2004-07-18
  • 打赏
  • 举报
回复
学习
学习!!

学习!!
学习!!

hooligan000112003 2004-07-18
  • 打赏
  • 举报
回复
学习!!
LCKKING 2004-07-18
  • 打赏
  • 举报
回复
当然可以。。代码如下:
import java.io.*;

public class Mac{
public static void main(String[] arg){
try{
java.lang.Process proc = Runtime.getRuntime().exec("ipconfig /all");
InputStream istr = proc.getInputStream();
byte[] data = new byte[1024];
istr.read(data);
String netdata = new String(data);
System.out.println("Your Mac Address="+procAll(netdata));
}catch(IOException e){
System.out.println("error="+e);
}
}
public static String procAll(String str){
return procStringEnd(procFirstMac(procAddress(str)));
}
public static String procAddress(String str){
int indexof = str.indexOf("Physical Address");
if(indexof>0)
return str.substring(indexof,str.length());
return str;
}
public static String procFirstMac(String str){
int indexof = str.indexOf(":");
if(indexof>0)
return str.substring(indexof+1,str.length()).trim();
return str;
}
public static String procStringEnd(String str){
int indexof = str.indexOf("\r");
if(indexof>0)
return str.substring(0,indexof).trim();
return str;
}
}
Neropro 2004-07-18
  • 打赏
  • 举报
回复
关注
LCKKING 2004-07-18
  • 打赏
  • 举报
回复
楼上的说的甚是
加载更多回复(6)

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧