You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ricky Lee <ja...@yahoo.com> on 2004/04/18 03:01:26 UTC
what should i do to set the session in the pageContext in a Action class?
hi, thanks for reading..
i have a problem about set the seesion(pageContext) in
the action class..
i know that set the seesion in the request, just like
request.getSession().setAttribute("login_username",userForm.getUsername());
and in the JSP page, we can use the code to get the
seesion:
<%=request.getSession().getAttribute("login_username")%>
but, i want to use the pageContext to set the session
so as to load the attribute in JSTL
<c:if test="${....}}">...</c:if>
if i use <c:if test="${session.login_username ==
null}">...</c:if> it can't work...
because there isn't login_username in the session
pageContext.
if i use <c:if
test="${request.getSession().getAttribute("login_username")
== null}">..</c:if>
it still cause a error....syntax error...
i know in the custom taglib, we can use the the
pageContext.setAttribute(String,Object,scope) the
scope can set to "session"
and in the JSP page, we can use the JSTL to get the
attribute..
but in the Action class , there isn't pageContext
object to set the session in the pageContext, just has
the request to set pageContext, what should i do to
set the session in the pageContext?
please help me....thanks!
__________________________________
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25�
http://photos.yahoo.com/ph/print_splash
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: what should i do to set the session in the pageContext in a Action
class?
Posted by Nathan Maves <Na...@Sun.COM>.
You might want to read up a little more in the jstl spec.
When using jstl there is no need to specify the scope. Just use
something like
<c:if test="${! empty login_user}" >
this will check if the login_user is null. The tag will search through
all the the scopes. (i.e. page, request, session, application)
Hope this helps.
Nathan
On Apr 17, 2004, at 7:01 PM, Ricky Lee wrote:
> hi, thanks for reading..
>
> i have a problem about set the seesion(pageContext) in
> the action class..
>
> i know that set the seesion in the request, just like
> request.getSession().setAttribute("login_username",userForm.getUsername
> ());
>
> and in the JSP page, we can use the code to get the
> seesion:
>
> <%=request.getSession().getAttribute("login_username")%>
>
> but, i want to use the pageContext to set the session
> so as to load the attribute in JSTL
>
> <c:if test="${....}}">...</c:if>
>
> if i use <c:if test="${session.login_username ==
> null}">...</c:if> it can't work...
>
> because there isn't login_username in the session
> pageContext.
>
> if i use <c:if
> test="${request.getSession().getAttribute("login_username")
> == null}">..</c:if>
>
> it still cause a error....syntax error...
>
> i know in the custom taglib, we can use the the
>
> pageContext.setAttribute(String,Object,scope) the
> scope can set to "session"
>
> and in the JSP page, we can use the JSTL to get the
> attribute..
>
>
> but in the Action class , there isn't pageContext
> object to set the session in the pageContext, just has
> the request to set pageContext, what should i do to
> set the session in the pageContext?
>
>
> please help me....thanks!
>
>
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Photos: High-quality 4x6 digital prints for 25¢
> http://photos.yahoo.com/ph/print_splash
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org