You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@beehive.apache.org by Timothy Brown <tb...@earthlink.net> on 2005/01/11 17:54:21 UTC
Session object access
I am trying to get access params in the session object from my jsp. I set
the authenticated_user param in my controller and want to display on my jsp.
Controller <code-snippet>
public Forward processLogin( LoginForm form )
{
if ( security.authenticate( form.getUsername(), form.getPassword() )
)
{
HttpServletRequest request = getRequest();
HttpSession session = request.getSession();
session.setAttribute( "authenticated_user", form.getUsername()
);
return new Forward( "authenticated" );
}
return new Forward( "not_authenticated" );
}
I have tried session.getAttribute("authenticated_user") and
<netui:label value="${session.authenticated_user}" />
I know I am missing something, but what.
Thanks,
Tim
Re: Session object access
Posted by Eddie O'Neil <ek...@bea.com>.
Tim--
In JSP 2.0 EL, you can bind to the session using an implicit object
named "sessionScope", so the binding expression would be:
${sessionScope.authenticated_user}
and in the label:
<netui:label value="${sessionScope.authenticated_user}"/>
Hope that helps.
Eddie
Timothy Brown wrote:
> I am trying to get access params in the session object from my jsp. I set
> the authenticated_user param in my controller and want to display on my jsp.
>
>
>
> Controller <code-snippet>
>
>
>
> public Forward processLogin( LoginForm form )
>
> {
>
> if ( security.authenticate( form.getUsername(), form.getPassword() )
> )
>
> {
>
> HttpServletRequest request = getRequest();
>
> HttpSession session = request.getSession();
>
>
>
> session.setAttribute( "authenticated_user", form.getUsername()
> );
>
>
>
> return new Forward( "authenticated" );
>
> }
>
> return new Forward( "not_authenticated" );
>
> }
>
>
>
> I have tried session.getAttribute("authenticated_user") and
>
>
>
> <netui:label value="${session.authenticated_user}" />
>
>
>
> I know I am missing something, but what.
>
>
>
> Thanks,
>
>
>
> Tim
>
>