HTTP Session issues  XML
Forum Index -> General Help
Author Message

Joined: 30/May/2008 00:00:00
Messages: 34


I have a Login app written using JSP/Servlet, this Login app adds an attribute to the HTTP Session with user credentials.

Other JSP/Servlet apps can access this HTTP Session attrib normally but my ICEFaces app does not contain this attribute when I try to access it, here is the code.

   	HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
      	HttpSession httpSession = request.getSession(false);
      	userData = (UserData) httpSession.getAttribute("userdata");

Am I doing something wrong to access the HTTP Session from JSF beans ?

I'm assuming HTTP session from a Servlet or JSF should be the same

Please let me know if you have any idea

Joined: 10/Feb/2005 00:00:00
Messages: 323

There's are separate HttpSession instance for each web-application. Is the Login application part of the same servlet context that contains the ICEfaces code or does it live separately?

Joined: 27/Nov/2006 00:00:00
Messages: 332

A little bit off topic maybe, but if you try to access some session scoped data in a managed bean (works only with request or extended request scoped beans), then one elegant way to do is as follows:
1. In your managed bean declare the private field UserData userData with getter and setter
2. In faces-config.xml, where you declared your managed-bean, add a managed property:

Then you will have your field populated by the container (it will not work in bean's constructor though, but then you could overcome that with a @PostConstruct annotated methdo).

Forum Index -> General Help
Go to:   
Powered by JForum 2.1.7ice © JForum Team