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

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


Hi

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.

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
mircea.toma

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


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?
[Email]
edykory


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


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:
Code:
<managed-bean>
 		<managed-bean-name>blablaBean</managed-bean-name>
  		<managed-bean-class>BlablaBean</managed-bean-class>
 		<managed-bean-scope>request</managed-bean-scope>
 		<managed-property>
 			<property-name>userData</property-name>
 			<value>#{sessionScope.userData}</value>
 		</managed-property>
 	</managed-bean>

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).

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