Andreas Buechler wrote:
Hi,
I'm trying to use jstl within my portlet but have some troubles getting
a simple forEach loop to work (see code snippet below). Are there
certain limitations on using jstl in portlets?
Regards,
Andi
// bean.getAllToys() returns a Vector
<c:forEach var="toy" items="<%= bean.getAllToys().elements() %>" >
<c:out value="${toy}" escapeXml="false" /><br />
</c:forEach>
Andreas, have you tried your snippet without a portlet (i.e. in a pure
Java webapplication)? Does it work there? JSTL works well within
portlets. There are some general limitation in invoking web components
from portlets, but I know nothing special for JSTL.
I assume your error relates on how you fill attributes with dynamic
values and has nothing to do with t eportlet environment. There are
different JSTL tags available for EL (${...}) and RT expr (<%= ... %>).
I am not sure which one you use, and whether it is allowed to mix it up
like that.
This simple example works in one of my portlets:
---
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%
java.util.Vector v = new java.util.Vector();
v.add("Bride of Pinbot Pinball");
v.add("Sun ULTRA-1");
pageContext.setAttribute("myToys", v);
%>
<c:forEach var="toy" items="${myToys}" >
<c:out value="${toy}" escapeXml="false" /><br />
</c:forEach>
---
Greetings from Hamburg,
Stefan