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 7571071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:34:56+00:00 2026-05-30T15:34:56+00:00

For other reasons I have to do a forEach loop on a jsp page

  • 0

For other reasons I have to do a forEach loop on a jsp page rather than iterating over a collection. I need to display the value of a collection, but I am returning a syntax error because of the inner braces..do I have to escape it first? How do I get it to resolve the value of i then to get the value from the colllection?

  <c:if test="${maxColumns >= 0}">  
     <c:forEach var="i" begin="0" end="${maxColumns}" step="1" varStatus ="status">
     <td height="20"> ${columnNames[${i}].columnName</td>
</c:forEach>
  </c:if>

Thanks for the help.

  • 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-30T15:34:57+00:00Added an answer on May 30, 2026 at 3:34 pm

    You cannot nest JSP EL expressions like that, but you don’t have to–the correct expression is:

    ${columnNames[i].columnName}
    

    i is already part of the EL scope because of the forEach tag, and should be evaluated as any other scoped variable, like columnNames. Here it’s just a collection index.

    While I’m sympathetic to the perceived need to do this kind of logic in the view layer, IMO it’s almost always a better idea to prep collection ranges in Java–it’s also easier to test.

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

Sidebar

Related Questions

Due to network or some other reasons, some sites do not have their css
I have the following code: <%= select_tag :role, options_for_select(Project::COMPANY_ROLES.concat(['Other...']), @relationship.role) %> For some reason
Which one is recommended considering readability, memory usage, other reasons? 1. String strSomething1 =
I suppose there could be historical reasons for this naming and that other languages
Is there any particular reason to use one over the other? I personally tend
Is there any reason to favor one of these approaches over the other when
I have the following smarty code: {foreach from=$additional_fields item=v} {if $v.fieldid eq 5} {php}
I have a build a website where users need to login to, and the
I have never written unit tests before, for various reasons. I have a chance
I have one go script that fetches any other script requested and this is

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.