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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:57:08+00:00 2026-06-14T00:57:08+00:00

I am wondering how I can iterate through a list array in a jsp

  • 0

I am wondering how I can iterate through a list array in a jsp page, where the list is defined in a custom java servlet.

This is what I have in the servlet:

request.setAttribute("TITLE", STRINGVALUE);

I can display the above code fragment with the following line:

${dashboard}

Now I am trying to use a foreach loop:

<c:forEach var="VARIABLE" items="??????">

The question consists of two sub questions:

  1. How can I use an array in the foreach statement, without using scriptlets?
  2. How can I print values of the array elements? For example, ${person.name} results in an error, as the program only sees a String.
  • 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-14T00:57:09+00:00Added an answer on June 14, 2026 at 12:57 am

    Basically, you need to have the List of your Objects in your session.

    Ex.

    List <Persons> myList = new ArrayList<Persons>();
    myList.add(p1);
    myList.add(p2);
    session.setAttribute("persons", myList );
    

    And then in your jsp you use it like this:

    <c:forEach items="${persons}" var="personBean">  
      ${personBean.lastName}, ${personBean.firstName} <br />  
    </c:forEach>  
    

    You can also see BalusC post in Iterate over elements of List and Map using JSTL <c:forEach> tag for more info

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

Sidebar

Related Questions

Hi I'm wondering how I can go about this problem I have a DB
How can one iterate through an array to manipulate or access different objects and
I have a need to iterate through an amortization formula, which looks like this:
I have some code in JSP as below: <c:iterate name=list id=payment index=idx> <tr class=gRowEven
As I'm a bit new to Grails, I'm wondering how I can iterate through
I was wondering how can I generate the following array using ranges in ruby
I was wondering how can I list the user tables name with its primary
I have an array of strings like this: test[1] = AA; test[2] = BB;
I'm wondering how to iterate over a List with mixed contents using foreach. See
Using this Java code: // create the items list List<Item> items = new ArrayList<Item>();

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.