JSF FacesContext and HttpServletRequest for Web Services in JSF Project
The FacesContext is created by the FacesServlet and thus only available within any Java code which is processed by the FacesServlet, which covers all JSF artifacts, such as managed beans and phase listeners. The FacesContext is just an abstraction of everything already available by standard Servlet API such as HttpServletRequest, HttpSession, ServletContext, etc. For web services, we can use them directly . JAX RS Implementation @Context private ServletConfig servletConfig; @Context private ServletContext servletContext; @Context private HttpServletRequest httpServletRequest; @Context private HttpServletResponse httpServletResponse; @POST @Path("/xxxx") @Produces("application/json") public RestResult<XXXResult> eee(@RequestBody inputParam parameter) throws BusinessRuleException { httpServletRequest.getSession().setAttribute(&quo