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

  • Home
  • SEARCH
  • 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 5962865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:09:57+00:00 2026-05-22T19:09:57+00:00

In my spring web application I have arraylist in model attribute which I want

  • 0

In my spring web application I have arraylist in model attribute which I want to show in table format in JSP. I need to arrange the list items in the two columns dynamically. Below is code which creates only one column but I need to arrange then in even odd pair in two columns.

 <table>
    <c:forEach items="${artifact.answerOptions}" var="answeroption" varStatus="status">
    <tr>
      <td>
      <form:radiobutton path="choosenAnswers" value="${answeroption}"/>
    <label for="choosenAnswers" class="lowerlabel"><c:out value="${answeroption.answerText}"/></label>
      </td>
    </tr>
    </c:forEach>
   </table>

Here answerOptions is the list of AnswerOption beans which has answerText property.
Above code creates table but with one column, but I need them to arrange in even odd manner like below:

<table>
  <tr>
     <td> List Item 1</td>
     <td> List Item 2</td>
  </tr>
  <tr>
     <td> List Item 3</td>
     <td> List Item 4</td>
  </tr>
  <tr>
     <td> List Item 5</td>
     <td> List Item 6</td>
  </tr>
</table>
  • 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-05-22T19:09:58+00:00Added an answer on May 22, 2026 at 7:09 pm

    Use the begin, end and step attributes instead. You could let it iterate by 2 and get the list items by index directly.

    <table>
      <c:forEach begin="0" end="${fn:length(artifact.answerOptions)}" step="2" varStatus="loop">
        <tr>
          <td>${artifact.answerOptions[loop.index]}</td>
          <td>${artifact.answerOptions[loop.index + 1]}</td>
        </tr>
      </c:forEach>
    </table>
    

    (no this doesn’t throw ArrayIndexOutOfBoundsException when you have odd amount of items)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application using JPA and JTA with Spring. I would like
I am using Spring MVC to build my web application, and I have a
We have a (non-web app) Spring application that throws a NoSuchBeanDefinitionException when running tests
I'm building a java/spring application, and i may need to incorporate a stateful web
I have two class definitions in my Spring MVC web application named Class and
I have a Wicket Web Application running in Tomcat. The application uses Spring (via
We have a Spring web application created using Spring MVC 3.0 In the same
I have web application on spring mvc and maven. When I execute mvn clean
I'm writing a web application using Spring/Hibernate that displays a report to a user,
I am using Spring Forms for my web application. For nested properties, the form

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.