title: Get client computer domain name / MAC
body: <p>I'm trying to get the client information in JSF application. But I'm able just to get IP address. </p>
  
  <p>I've tried this:</p>
  
  <pre><code>HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
  System.err.println(request.getRemoteAddr());
  System.err.println(request.getRemoteHost());
  </code></pre>
  
  <p>Problem is that <code>request.getRemoteAddr()</code> and <code>request.getRemoteHost()</code> both gets the IP address. </p>
  
  <p>Is there some way to get client domain name or its MAC address?</p>
  
  <p><strong>UPDATE (solution):</strong></p>
  
  <pre><code>HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
  
  String ipAddress = request.getHeader("X-FORWARDED-FOR");
  if (ipAddress == null) ipAddress = request.getRemoteAddr();  // IP
  
  InetAddress addr = InetAddress.getByName(ipAddress);  // DOMAIN NAME from IP
  String host = addr.getHostName();
  </code></pre>