Finding user ip address

前端 未结 3 1196
执笔经年
执笔经年 2020-12-13 09:48

I have created web application using JSF 2.0. I have hosted it on hosting site and the server of the hosting site is based in US.

My client want the details of the u

3条回答
  •  一整个雨季
    2020-12-13 10:18

    I went ahead with

    HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
    String ipAddress = request.getHeader("X-FORWARDED-FOR");
    if (ipAddress == null) {
        ipAddress = request.getRemoteAddr();
    }
    System.out.println("ipAddress:" + ipAddress);
    

提交回复
热议问题