当然可以。。代码如下:
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;
}
}

解决方案 »

  1.   

    这就存在安全问题。
    如果可以实现运行ipconfig 
    是不是可以实现一运行网面电脑就重启呢?
      

  2.   

    这个是服务器端的网卡信息,不是客户端的
    而且如果操作系统非win就会发生错误
      

  3.   

    ,+***+,                                     
        ,*********,  ,               ,@@,             
       .****+++****,*:               ,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/做的。
      

  4.   

    再说了Jsp是服务器端执行的程序,request里又没有包含客户端的Mac地址。要是做的话我认为需要客户端的JavaScript和服务器端的JSP配合才可以实现
      

  5.   

    别抱任何幻想了,纯JSP绝对做不到。
      

  6.   

    <%@ 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> 
      

  7.   

    这个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);
      }}