If you have an Exception use this line instead of it : FacesContext.getCurrentInstance().getExternalContext().getRequest().getSession().setAttribute("myKey") = myValue;