On Fri, 6 Dec 2002, Hao Ding wrote:

> Hi all,
> 
> I got a question which confused me for several days. I hava a collection 
> and I want to set each item of the collection to a set of variables. Can 
> I do it using <c:forEach> tag and how to access these variables?
> 
> For example:
> <c:forEach var="legend" items="${list.legendBuf}" varStatus="status">
>      <c:set var="fea${status.count}" scope="session" value="${legend}"/>
> </c:forEach>
> 
> Can I do like that? If yes, how to access these variables. Can I write 
> <... value="${fea${num}}">, where the value of variable "num" could be 
> 1, 2 , ...

You can't use a dynamic 'var', but you can use a different syntax of
<c:set> that lets you set the values of elements in a Map, as in

  <c:set target="${myMap}" property="${keyName}" value="${newValue}" />

Then, you can refer to what you have just set with expressions like

  ${myMap[keyName]}

Hope that helps,

Shawn


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to