I get some user data through a simple form. When you work with data in the corresponding bean support method, I currently get the user's IP address this way:
HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest(); String ipAddress = request.getHeader( "X-FORWARDED-FOR" ); if ( ipAddress == null ) { ipAddress = request.getRemoteAddr(); }
Is there any other way, more "JSF", where I do not need to cling to the HttpServletRequest ? I read many times that using javax.servlet.* In @ManagedBean not a good design, but I could not find anything.
source share