You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Matt Raible <ma...@raibledesigns.com> on 2002/04/24 07:01:13 UTC

c:forEach compared to logic:iterate

I'm using the logic:iterate tag in the following manner:

<logic:iterate id="pageInfo" name="topicForm" property="pages">
    <html:link forward="getPage"
        name="pageInfo" property="pageTopicMap"
title="<%=((PageForm)pageInfo).getName()%>">
        <c:out value="${pageInfo.pageSequence + 1}"/>
    </html:link>
</logic:iterate>

Which works great!  However, I was hoping to migrate my logic tags to
JSTL and the following doesn't work:

<c:forEach var="pageInfo" items="${topicForm.pages}">
    <html:link forward="getPage"
        name="pageInfo" property="pageTopicMap"
title="<%=((PageForm)pageInfo).getName()%>">
        <c:out value="${pageInfo.pageSequence + 1}"/>
    </html:link>  
</c:forEach>

However, I get the following error when I try this:

 [ServletException in:/viewer/coursePage.jsp] Unable to compile class
for JSP An error occured between lines: 83 and 84 in the jsp file:
/viewer/coursePage.jsp Generated servlet error:
D:\Tools\tomcat-4.0.1\work\localhost\onpoint\viewer\coursePage$jsp.java:
743: Undefined variable: pageInfo
_jspx_th_html_link_0.setTitle(((PageForm)pageInfo).getName()); ^ 1 error
' 




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: c:forEach compared to logic:iterate

Posted by Shawn Bayern <ba...@essentially.net>.
On Tue, 23 Apr 2002, Matt Raible wrote:

> Which works great!  However, I was hoping to migrate my logic tags to
> JSTL and the following doesn't work:
> 
> <c:forEach var="pageInfo" items="${topicForm.pages}">
>     <html:link forward="getPage"
>         name="pageInfo" property="pageTopicMap"
> title="<%=((PageForm)pageInfo).getName()%>">

JSTL's <c:forEach> tag doesn't expose a scripting variable, just a scoped
attribute (which we call a "scoped variable").  You need to use
<jsp:useBean> (or some other declaration mechanism) if you absolutely need
scripting variables.

Though I can't speak for Struts, my sense is that it is planning to
accommodate JSTL's expression language (at the very least under JSP 1.3,
where it will be the container's responsibility), which will minimize the
need for scripting variables.

Hope that helps,

-- 
Shawn Bayern
"JSP Standard Tag Library"   http://www.jstlbook.com
(coming this summer from Manning Publications)


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>