1. obtain the Client IP address (this must be uploaded from the client to the backend): Under the jsp page, it is very simple, request. getRemoteAddr (); because the VIew layer of the system is implemented using JSF, the page cannot directly obtain similar requests, A forced conversion [java] public String getMyIP () {try {FacesContext fc = FacesContext is made in bean. getCurrentInstance (); HttpServletRequest request = (HttpServletRequest) fc. getExternalContext (). getRequest (); return request. getRemoteAddr ();} catch (Exception e) {e. printStackTrace ();} return "";} 2. obtain the client mac address Call the window command to obtain the mac address through the ip address in the backend Bean. The method is as follows: [java] public String getMACAddress (String ip) {String str = ""; String macAddress = ""; try {Process p = runtime.getruntime(cmd.exe c ("nbtstat-A" + ip); InputStreamReader ir = new InputStreamReader (p. getInputStream (); LineNumberReader input = new LineNumberReader (ir); for (int I = 1; I <100; I ++) {str = input. readLine (); if (str! = Null) {if (str. indexOf ("MAC Address")> 1) {macAddress = str. substring (str. indexOf ("MAC Address") + 14, str. length (); break ;}}} catch (IOException e) {e. printStackTrace (System. out);} return macAddress;} added: Recently, I learned a lesson about how to obtain an IP address in linux. If you simply use InetAddress to obtain an IP address, the IP address is different on different machines. InetAddress. getLocalHost (). getAddress () actually obtains the IP address based on the hostname. In linux, the default hostname is localhost. Therefore, the local ip address obtained through the code above is 127.0.0.1. For example, my hostname is the ip address returned by linlin.atsig.com. It is indeed the address of atsig.com. Currently, the following code is not flexible enough: [java] public static byte [] getIp () throws UnknownHostException {byte [] B = InetAddress. getLocalHost (). getAddress (); Enumeration allNetInterfaces = null; try {allNetInterfaces = NetworkInterface. getNetworkInterfaces ();} catch (SocketException e) {e. printStackTrace ();} InetAddress ip = null; NetworkInterface netInterface = null; while (allNetInterfaces. hasMoreElements () {n EtInterface = (NetworkInterface) allNetInterfaces. nextElement (); if (netInterface. getName (). trim (). equals ("eth0") {Enumeration addresses = netInterface. getInetAddresses (); while (addresses. hasMoreElements () {ip = (InetAddress) addresses. nextElement () ;}break ;}} if (ip! = Null & ip instanceof Inet4Address) {return B = ip. getAddress ();} return B ;}