JSF get a session attribute in back bean
843842Aug 2 2006 — edited Oct 31 2008Hi to everyone,
I've a jsf page, in this page i'm setting a session attribute with this code:
<%request.setAttribute("user", "admin"); %>
i've a submit button with action like this:
<h:commandButton styleClass="aButton" value="Aggiorna"
style="vertical-align:middle;" action="# {UserBean.update}"/>
In the method updatei want retrive the attribute "user" so i've write this code in update function:
FacesContext ctx = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest)ctx.getExternalContext().getRequest();
//LoginBean lb = (LoginBean) app.createValueBinding("#{login}).getValue(ctx);
user = (String)request.getAttribute("user");
but the user is null, why?
Can someone help me?
Thanks, Fabio.