0 Replies Latest reply on Oct 12, 2004 11:16 AM by chrismalan

    request.getRemoteAddr()

    chrismalan

      Dear All,

      How does one get the IP Address of whoever initiated the request?

      I tried:

      if (request.getHeader("HTTP_X_FORWARDED_FOR") == null)
      IPAddr = request.getRemoteAddr();
      else
      IPAddr = request.getHeader("HTTP_X_FORWARDED_FOR");

      This should check for proxies and return the correct IP Address, unfortunately it returns only a local IP Address viz 127.0.0.16

      This is JBoss 3.2.0 with Jetty running at Alacartejava.

      In the next appliation I will need to get the IP Address to map the user to a country to display the correct ad on the site.

      Thanks,

      Chris