tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Bayern <bay...@essentially.net>
Subject Re: How to Use a forEach Variable in Scriptlet
Date Fri, 10 Jan 2003 15:01:13 GMT
On Fri, 10 Jan 2003, Paul Hodgetts, Agile Logic wrote:

> If I have a forEach tag:
>    <c:forEach items="${x.y}" var="z">
> 
> How can I access the variable "z" in a scriptlet?
> Something like:
> 
> <% String a = z.name() %>
> 
> but that gives a compiler error when it tries to
> compile the JSP page.  My understanding is that
> z gets put in page scope, but I don't know how to
> access it from there.

JSTL tags don't expose scripting variables.  You'd need either to insert a
<jsp:useBean> tag or to refer to the scoped attribute, as in

 <% String a = ((MyClass) pageContext.getAttribute("x")).getName(); %>

-- 
Shawn Bayern
"JSTL in Action"   http://www.manning.com/bayern


--
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