tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vernon Wu <vern...@gatewaytech.com>
Subject Re: Is a way to access/retrieve an attribute in the session scope using JSTL
Date Wed, 07 Aug 2002 05:20:25 GMT

Hi, Shawn,

I guess that I was tired and didn't read the chapter carefully.

The tag I need is 

<c:set value="${...}" target="${helper}" property="hostID"/>

where the 'value' is request.getSession().getAttribute(WebKeys.UserID)

and the 'WebKeys' is an interface containing keys to store data. Its code fragment is:

public interface WebKeys {
    public static final String UserID = "com.vernonwu.mm.UserID";
	// ...
}

Based on your suggestions, I have tried various expressions without a luck. I guess the problem
is either the interface, 
or  the static string type.

 

8/6/2002 3:29:13 PM, Shawn Bayern <bayern@essentially.net> wrote:

>Hi Vernon,
>
>> I have read the chapter 3 of Shawn's book last night. I thought I
>> could find out how to access an attribute in the session scope after
>> the page scope mentioned in the chapter. The chapter, however, doesn'
>> mention the topic.
>
>Sure it does - see section 3.2 (specifically p. 49 and table 3.2).
>
>> Is an equivalent JSTL tag for the script
>> 
>> <%request.getSession().getAttribute(WebKeys.UserID)%>
>
>You'd use 'sessionScope'.  I'm not clear what "WebKeys.UserID" is, but if
>you had
>
> request.getSession().getAttribute(foo)
>
>this would be equivalent to the JSTL EL expression
>
> ${sessionScope[foo]}
>
>If it were
>
> request.getSession().getAttribute(foo)
>
>then you could write either of the following:
>
> ${sessionScope.foo}
>
>or
>
> ${sessionScope["foo"]}
>
>Hope that helps; please let us know if you've got any further questions.
>
>-- 
>Shawn Bayern
>"JSTL in Action"   http://www.jstlbook.com
>
>




--
To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>


Mime
View raw message