ssh2 action中如何获取客户端的信息
电脑名称  使用 getRequest().getRemoteAddr();和getRequest().getRemoteHost();获取的均是IP地址
请问 用什么方法可以准确获取 客户端电脑名称MAC 客户端物流地址用什么办法获取

解决方案 »

  1.   

    HttpServletRequestrequest= ServletActionContext.getRequest();
      

  2.   

    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.net.InetAddress;
    /*
     * Created on 2006/8/1
     *
     * TODO To change the template for this generated file go to
     * Window - Preferences - Java - Code Style - Code Templates
     */
    /**
     * @author Administrator
     *
     * TODO To change the template for this generated type comment go to
     * Window - Preferences - Java - Code Style - Code Templates
     */
    public 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 static void main(String[] args) {
      //InetAddress.getLocalHost().getHostAddress();
      try{
       InetAddress.getLocalHost(); 
       System.out.println("host name="+InetAddress.getLocalHost().getHostName());
       System.out.println("ip ="+InetAddress.getLocalHost().getHostAddress());
      }catch(Exception ex){
       //
      }
      
      System.out.println("mac ="+GetMac.getMacOnWindow());
     }
    }
      

  3.   

    上述方法是获取服务器端的地址信息  我想要得到客户端的MAC 和电脑名称 怎么办呢
      

  4.   

    web客户端有什么技术可以获取到MAC 和电脑名称的,例如javascript等
      

  5.   

    客户端访问的时候,通过http协议发消息,不会携带客户端的电脑名称,所以取不到;
    只能采用别的方式,让客户端发送自己的名称
      

  6.   


    我跟你说,用java,只有applet一路可走。你百度去吧!