You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "vineesh . kumar" <vi...@rediffmail.com> on 2004/08/16 12:01:26 UTC
Accessing Session attribute from action
Hi all,
I wanna do store two values in the session when one logs in and i have to access the two values throughout the pages.also i have to access these two variables from some action classes. How can i do this
thanks,
vinu
Re: Accessing Session attribute from action
Posted by Erik Weber <er...@mindspring.com>.
Implement a checkLogin method in a base Action class that returns a User
object or similar, whatever you need. This method takes an argument of
type HttpServletRequest and looks for the User object in the request's
HttpSession. Your Login Action would set this attribute, and your Logout
Action would remove it.
Make all your actions extend the base Action class, then you can
retrieve your User object (if there is one) from any Action. You can
also access the objects in JSPs since they are just Session attributes.
For example:
<logic:present scope="session" name="User_object_attribute_key">
<!-- user apparently is logged in -->
</logic:present>
Hope that helps,
Erik
vineesh . kumar wrote:
>
>Hi all,
> I wanna do store two values in the session when one logs in and i have to access the two values throughout the pages.also i have to access these two variables from some action classes. How can i do this
> thanks,
> vinu
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Accessing Session attribute from action
Posted by Rajesh <ra...@gkbcinc.com>.
Hai
use request.getSession();
u can access from request object.
vineesh . kumar wrote:
>
>Hi all,
> I wanna do store two values in the session when one logs in and i have to access the two values throughout the pages.also i have to access these two variables from some action classes. How can i do this
> thanks,
> vinu
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org