Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8578041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:17:49+00:00 2026-06-11T20:17:49+00:00

I have searched through for this logic pretty much everywhere but am sure I

  • 0

I have searched through for this logic pretty much everywhere but am sure I haven’t done a great job and hence this question.

I have an Arraylist and it needs to be iterated and displayed in the following format

User1 User2 User3
User4 User5 User6
User7 User8 User9

I am able to do this using normal JSP scriptlets but not using JSTL. I have tried using JSTL but it skips a few entries from the list. Here is my code

    <tr>
        <c:forEach var="party" items="${partiesList}">
        <c:set var="ctr" value="${ctr+1}" scope="page"/>
        <c:choose>
        <c:when test="${ctr le 3}">
            <td>
                <figure>
                    <img src="images/${party.avatarUrl}" onclick="showHide('','${party.screenName}')" class="avaimg" alt="${party.screenName}">
                    <figcaption><spring:message code="user.${party.screenName}" text="${party.screenName}"/></figcaption>
                </figure>
            </td>
        </c:when>
        <c:otherwise>
    </tr>
    <c:set var="ctr" value="0" scope="page"/>
    </c:otherwise>
    </c:choose>
    </c:forEach>

Any help would be appreciated.

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:17:50+00:00Added an answer on June 11, 2026 at 8:17 pm

    You can do this by using the varStatus attribute and the modulo operator (%).

    <table>
      <c:forEach var="party" items="${partiesList}" varStatus="status">
        <c:if test="${status.index % 3 == 0}"><tr></c:if>
        <td>${status.index}</td>
        <c:if test="${status.index % 3 == 2}"></tr></c:if>
      </c:forEach>
    </table>
    

    varStatus will return a LoopTagStatus object, where index is

    The index of the current round of the iteration. If iteration is being performed over a subset of an underlying array, java.lang.Collection, or other type, the index returned is absolute with respect to the underlying collection. Indices are 0-based.

    You can use the modulo operator to check if you need to start or close a new row.


    A different approach would be just looping through the list, output it as an unnumbered list and use CSS to style it the way you want. That’s how I would have solved it. An example of how your CSS could look:

    ul.my-class { overflow: hidden; width: 600px; }
    ul.my-class li { float: left; width: 200px; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have searched through many times but have not seen this before. Probably really
I realise this may be a duplicate, but I have searched through many forums
I have searched through google and SO for possible answers to this question, but
this might be the easiest problem to solve but I have searched through the
I have searched this site and Google and even though the idea is pretty
I have searched for a general solution to this but only find answers to
I have searched through Google, SO and Android developers but I need some further
I'm rather new to ClearCase but have searched through a lot of solutions to
I have searched through internet & found that there are no any direct method
I have searched through the net and still have no clue how to do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.