ssh2 action中如何获取客户端的信息
电脑名称 使用 getRequest().getRemoteAddr();和getRequest().getRemoteHost();获取的均是IP地址
请问 用什么方法可以准确获取 客户端电脑名称MAC 客户端物流地址用什么办法获取
电脑名称 使用 getRequest().getRemoteAddr();和getRequest().getRemoteHost();获取的均是IP地址
请问 用什么方法可以准确获取 客户端电脑名称MAC 客户端物流地址用什么办法获取
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());
}
}
只能采用别的方式,让客户端发送自己的名称
我跟你说,用java,只有applet一路可走。你百度去吧!