JSTL limit forEach

Posted on 2006-05-16
Last Modified: 2013-11-24
If im doing c:forEach and outputting the results is there a way to limit the number of results you can display ?

many thanks.
Question by:Eternal_Student
    LVL 11

    Accepted Solution

    i would prefer to limit the results in the model itself. I mean, you should pass only those "items" you wish to display.
    Or you can limit it using local variables like in the following link
    LVL 18

    Author Comment

    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>

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

    LVL 18

    Author Comment

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

    I got it ^. Thanks for the link fargo.
    LVL 11

    Expert Comment

    good that it works. But why grade B?

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    What does @EnableWebMvc annotation in spring do 2 86
    Multiple issues with Java 14 37
    bigDiff challenge 17 60
    wordlen challenge 3 30
    I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    The viewer will learn how to implement Singleton Design Pattern in Java.
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now