Link to home
Start Free TrialLog in
Avatar of Eternal_Student
Eternal_StudentFlag for United Kingdom of Great Britain and Northern Ireland

asked on

JSTL limit forEach

If im doing c:forEach and outputting the results is there a way to limit the number of results you can display ?

many thanks.
ASKER CERTIFIED SOLUTION
Avatar of fargo
fargo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Eternal_Student

ASKER

ok, I tried something like this:

<gc:moviesList var="movies" />
            <c:forEach var="movie" items="${movies}" varStatus="status">                  
                  <c:if test="${status.count = }">
                        <a href="/sctv/movie.jsp?movieId=<c:out value="${movie.ID}" />"><c:out value="${movie.title}" /></a>
                  </c:if>                                          
            </c:forEach>

But im not sure how would set the status.count to equal 3. So it ONLY pulls out three results ?

<c:if test="${status.count <= 3 }">

I got it ^. Thanks for the link fargo.
Avatar of fargo
fargo

good that it works. But why grade B?