好像只能得到客户端IP吧,或者你在客户端也写个同样的getMacOnWindow(),然后自动发来不就得了.不要告诉我你要用在JSP上.

解决方案 »

  1.   

    ZT,没测试
    方法一:调用Windows的DOS命令,从输出结果中读取MAC地址:public static String getMACAddress() {String address = "";
    String os = System.getProperty("os.name");
    if ( os != null && os.startsWith("Windows")) {
    try {
    String command = "cmd.exe /c ipconfig /all";
    Process p = Runtime.getRuntime().exec(command);
    BufferedReader br =
    new BufferedReader(
    new InputStreamReader(p.getInputStream()));
    String line;
    while ((line = br.readLine()) != null) {
    if (line.indexOf("Physical Address") > 0) {
    int index = line.indexOf(":");
    index += 2;
    address = line.substring(index);
    break;
    }
    }
    br.close();
    return address.trim();
    }
    catch (IOException e) { }
    }
    return address;
    }We can replace the "ipconfig" to "ping x.x.x.x" and "arp -a"...We can get the mac list...haha!!
    缺点:只能取得服务器端MAC地址.如果要取得客户端的MAC地址,需用Applet.只针对MS-WIN系统. 方法二:可以用JS或vbscript来调用WMI接口来获取Client端的MAC地址.
      

  2.   

    顺便问一下,有没有在unix\linux服务器系统上获得mac地址的原代码呢?
      

  3.   

    yyri(行云)谢谢你提供的方法,但是你的方法还是只能得到服务器端的MAC地址,得到不到客房端的。
      

  4.   

    用java调命令IPconfig -all就可以得到了
      

  5.   

    在Windows 9x 中可用WinIPcfg获得,在Windows 2000/XP中可用IPconfig -all获得
      

  6.   

    web?
    http协议可以吗?
    写个applet下载到客户端(需要数字签名)执行。
      

  7.   

    必须得能在客户端执行查看ip的命令才行,不知道你是怎样的系统,web还是application
      

  8.   

    必须在同一网段中,用arp命令获取
      

  9.   

    嗯大家提到的都是问题,如果是windows系统的话,我觉的写一个applet可以实现。但我想要的还是有一个方法,在服务器上运行就可以得到客户的MAC地址。谢谢大家的支持。请继续关注这个话题!!!
      

  10.   

    服务器上得到的数据都是从request里取出来得。
    除非你在客户端得到放到request里。
      

  11.   

    单纯的java是不可能做到的,因为java对于 网络层以下(包括网络层)就不支持了.
      

  12.   

    客户操作系统必须是2000以上的,而且必须降低IE安全级别至最低,在项目实际运用中不是很实用!
    代码如下:
             <SCRIPT LANGUAGE="JavaScript">
    function getMacAddress(f)
    {
    try
    {
    var address = new Array();
    var i = 0;
    var wsh = new ActiveXObject("WScript.Shell");
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    wsh.Run("cmd /C ipconfig /all > c:\\temp.txt",0);
    //alert("1")
    var file = fso.OpenTextFile("c:\\temp.txt",1);
    //alert("2")
    var currentLine;
    var colon;
    while(file.AtEndOfStream!=true)
    {
    currentLine = file.ReadLine();
    if(currentLine.indexOf("Physical Address") >= 0)
    {
    colon = currentLine.indexOf(":");
    address[i] = currentLine.substr(colon + 1);
    //alert(address[i]);
    f.macname.value = address[i];
    i++;
    }     
    }
    file.Close()
    f = fso.GetFile("c:\\temp.txt");
    f.Delete();
    }
    catch(e)
    {
    alert("请您将IE安全级别降至最低,然后刷新页面!");
    }
    }
             <SCRIPT>
      

  13.   

    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.io.*;
    class GetMac
    {
    private static String getMacOnWindow() {
            String s = "";
            try {
                String s1 = "ipconfig /all";
                Process process = Runtime.getRuntime().exec(s1);
                BufferedReader bufferedreader = new BufferedReader(
                        new InputStreamReader(process.getInputStream()));
                String nextLine;
                for (String line = bufferedreader.readLine(); line != null; line = nextLine) {
                    nextLine = bufferedreader.readLine();
                    if (line.indexOf("Physical Address") <= 0) {
                        continue;
                    }
                    int i = line.indexOf("Physical Address") + 36;
                    s = line.substring(i);
                    break;
                }            bufferedreader.close();
                process.waitFor();
            } catch (Exception exception) {
                s = "";
            }
            return s.trim();
        }
     }
    public class GetMacOnWindow 
    {
    public static void main(String[] args) 
    {
        System.out.println(GetMac.getMacOnWindow());
    }
    }
    (以上资料来自我参于的一个贴子,仅供学习交流)
      

  14.   

    各位都是高手呀。呵呵收益非浅,我想提提我的想法,我觉得如果是WEB方式的话,是否可以在请求页面中编写JAVASCRIPT代码检测MAC地址,生成一个REQUEST的访问字段,然后通过REQUEST发送到服务器端,自然就可以揭开了,但是因为我对JAVASCRIPT不熟悉,是否有这方面的函数,我就不晓得了。