转载自:http://blog.sina.com.cn/s/blog_872758480100waew.html
为了保持向后兼容,我们有时可能会需要访问session对象。在JSF中可以通过如下方式来获取session.
HttpSession session = (ServletContext)FacesContext.getCurrentInstance().getExternalContext().getSession(false);
获取request对象的方式也比较相似
HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();