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 Allistair Crossley <Al...@QAS.com> on 2004/05/25 14:30:15 UTC

Iteration over Collection

Hi guys, simple but annoying problem .. have been following documentation but does not happen for me. I have a ArrayList in the request as "newStarters". I have tried the following:

Attempt 1
=========

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<c:forEach var="newStarter" items="${requestScope.newStarters}">
  	x
  	<br />
</c:forEach>

Attempt 2
=========

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<jsp:useBean id="newStarters" class="java.util.ArrayList" scope="request" />
<%= newStarters.size() %>

<c:forEach var="newStarter" items="${requestScope.newStarters}">
  	x
  	<br />
</c:forEach>

In this attempt I output the size of my collection and it is 10. I would interested how to output the size using EL too. I tried

<c:out value="requestScope.newStarters.size" />

Can anyone help


<FONT SIZE=1 FACE="VERDANA,ARIAL" COLOR=BLUE> 
-------------------------------------------------------
QAS Ltd.
Developers of QuickAddress Software
<a href="http://www.qas.com">www.qas.com</a>
Registered in England: No 2582055
Registered in Australia: No 082 851 474
-------------------------------------------------------
</FONT>


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


Re: Iteration over Collection

Posted by Helios Alonso <ha...@atg.com.uy>.
Remember that "${bean.property}" maps to "bean.getProperty()" so 
arraylist.size doesn't do the trick.

At 08:36 25/05/2004 -0400, you wrote:
>It looks like you're using JSTL 1.1 so you can use its length function:
>
><%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
>
>${fn:length(requestScope.newStarters)}
>
>Quoting Allistair Crossley <Al...@QAS.com>:
>
> > Hi guys, simple but annoying problem .. have been following 
> documentation but
> > does not happen for me. I have a ArrayList in the request as 
> "newStarters". I
> > have tried the following:
> >
> > Attempt 1
> > =========
> >
> > <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
> >
> > <c:forEach var="newStarter" items="${requestScope.newStarters}">
> >       x
> >       <br />
> > </c:forEach>
> >
> > Attempt 2
> > =========
> >
> > <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
> >
> > <jsp:useBean id="newStarters" class="java.util.ArrayList" 
> scope="request" />
> > <%= newStarters.size() %>
> >
> > <c:forEach var="newStarter" items="${requestScope.newStarters}">
> >       x
> >       <br />
> > </c:forEach>
> >
> > In this attempt I output the size of my collection and it is 10. I would
> > interested how to output the size using EL too. I tried
> >
> > <c:out value="requestScope.newStarters.size" />
> >
> > Can anyone help
> >
> >
> > <FONT SIZE=1 FACE="VERDANA,ARIAL" COLOR=BLUE>
> > -------------------------------------------------------
> > QAS Ltd.
> > Developers of QuickAddress Software
> > <a href="http://www.qas.com">www.qas.com</a>
> > Registered in England: No 2582055
> > Registered in Australia: No 082 851 474
> > -------------------------------------------------------
> > </FONT>
>
>--
>Kris Schneider <ma...@dotech.com>
>D.O.Tech       <http://www.dotech.com/>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org



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


Re: Iteration over Collection

Posted by Kris Schneider <kr...@dotech.com>.
It looks like you're using JSTL 1.1 so you can use its length function:

<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

${fn:length(requestScope.newStarters)}

Quoting Allistair Crossley <Al...@QAS.com>:

> Hi guys, simple but annoying problem .. have been following documentation but
> does not happen for me. I have a ArrayList in the request as "newStarters". I
> have tried the following:
> 
> Attempt 1
> =========
> 
> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
> 
> <c:forEach var="newStarter" items="${requestScope.newStarters}">
>   	x
>   	<br />
> </c:forEach>
> 
> Attempt 2
> =========
> 
> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
> 
> <jsp:useBean id="newStarters" class="java.util.ArrayList" scope="request" />
> <%= newStarters.size() %>
> 
> <c:forEach var="newStarter" items="${requestScope.newStarters}">
>   	x
>   	<br />
> </c:forEach>
> 
> In this attempt I output the size of my collection and it is 10. I would
> interested how to output the size using EL too. I tried
> 
> <c:out value="requestScope.newStarters.size" />
> 
> Can anyone help
> 
> 
> <FONT SIZE=1 FACE="VERDANA,ARIAL" COLOR=BLUE> 
> -------------------------------------------------------
> QAS Ltd.
> Developers of QuickAddress Software
> <a href="http://www.qas.com">www.qas.com</a>
> Registered in England: No 2582055
> Registered in Australia: No 082 851 474
> -------------------------------------------------------
> </FONT>

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

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