Hi,
I'm subramanian, i'm new for JSF framework. I need to know how we get the session variable value which we already set by using of bean property value in faces-config.xml file.
In faces-config.xml we give the session for your bean...
<managed-bean>
<managed-bean-name>login</managed-bean-name>
<managed-bean-class>LoginBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
So in above example... all parameter are session scope which is resides in LoginBean.. right...
U just assume... userId is the parameter... that is the session variable which is resides in LoginBean...
now i need to get the value of userId from another JSP page..
i try myself..
Object ss=session.getAttribute("userId");
Object vv=session.getValue("userId");
String rr=request.getParameter("login.userId");
but it's retrieve only null value...
i don't know whether the session varible not set properly or i made mistake to retrieve the session varible...
please help me.. it's very urgent..
Regards,
Subbus
-
how to get the session varibale value in JSF (5 messages)
- Posted by: subramanian subbiah
- Posted on: May 25 2005 05:50 EDT
Threaded Messages (5)
- how to get the session varibale value in JSF by Saniya A on May 25 2005 14:31 EDT
- Seesion Variable in JSF by subramanian subbiah on May 26 2005 00:32 EDT
-
Seesion Variable in JSF by Duncan Mills on May 26 2005 12:04 EDT
- Slight Typo by Duncan Mills on May 26 2005 12:05 EDT
- Session variable in jsf by subramanian subbiah on May 30 2005 12:59 EDT
-
Seesion Variable in JSF by Duncan Mills on May 26 2005 12:04 EDT
- Seesion Variable in JSF by subramanian subbiah on May 26 2005 00:32 EDT
-
how to get the session varibale value in JSF[ Go to top ]
- Posted by: Saniya A
- Posted on: May 25 2005 14:31 EDT
- in response to subramanian subbiah
Hi,
From what you are saying, it seems like you are receiving the userid from some jsp, i.e. an input that is coming from the user in a request.
So to retrieve that you would do somethign simmilar to what you do in servlets.. i.e. from the HTTPServletRequest retreive the value for what the user has sent you in your LoginBean. And once you retreive the value set your userId in the LoginBean to whatever value you retreived and now it would be set in the session and you can retreive it anytime you want.. but you cant expect to retreive it if its not set first..
Hope it helps.. -
Seesion Variable in JSF[ Go to top ]
- Posted by: subramanian subbiah
- Posted on: May 26 2005 00:32 EDT
- in response to Saniya A
Hi,
Thanks for your response, Exactly correct what you are saying .. but if u r using JSF framework, u need to mention the scope of bean in faces-config.. so in that face-config.xml u have to mention the "session" is the scope for LoginBean(already i wrote the code).. now the session scope set to the LoginBean and all the parameters also... (for example userId)
What i'm asking is.. how i get the session parameter...
Could u please give any example for handling session in JSF framework
Regards
Subbus -
Seesion Variable in JSF[ Go to top ]
- Posted by: Duncan Mills
- Posted on: May 26 2005 12:04 EDT
- in response to subramanian subbiah
There are two ways of doing this:
1) The "Right" way
FacesContext ctx = FacesContext.getCurrentInstance();
Application app = ctx.getApplication();
LoginBean lb = (LoginBean)app.createValueBinding("#{login}).getValue(ctx);
2) Use getExternalContext() on the Faces context which will give you access to the request and session objects directly. -
Slight Typo[ Go to top ]
- Posted by: Duncan Mills
- Posted on: May 26 2005 12:05 EDT
- in response to Duncan Mills
Missed the closing quote from the first example but you get the idea. -
Session variable in jsf[ Go to top ]
- Posted by: subramanian subbiah
- Posted on: May 30 2005 00:59 EDT
- in response to Duncan Mills
Thanks Duncan,
But it's not working .. still it's showing some error.. could u please tell me where should i write that code in Logout jsp or backend bean with u r send to me..
And one more doubt.. here u mention
Application app=ctx.getApplication();....
In above Application as u mention Application scope of our bean or that is any other class for handling session scope..
if u have free time plz give example program for that..
Thanking you
Subbus