Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JSF get a session attribute in back bean

843842Aug 2 2006 — edited Oct 31 2008
Hi 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.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 28 2008
Added on Aug 2 2006
8 comments
2,563 views