Oct 25, 2013

IP tracking of Remote address in ADF


To trace IP address of system which is opening page on its web browser following code is used.

      import javax.faces.context.ExternalContext;
      import javax.faces.context.FacesContext;


     FacesContext ctx = FacesContext.getCurrentInstance();

     HttpServletRequest request = (HttpServletRequest)ctx.getExternalContext().getRequest();

     request.getRemoteAddr();

If there is a need to get server IP address then code will be as follows
    
      FacesContext ctx = FacesContext.getCurrentInstance(); 

      HttpServletRequest request = (HttpServletRequest)ctx.getExternalContext().getRequest();

      request.getLocalAddr();

No comments:

Post a Comment