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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:40:05+00:00 2026-05-13T12:40:05+00:00

I have a map like this, Map<Integer,ArrayList<Object>> myMap = new LinkedHashMap<Integer,ArrayList<Object>>(); Now I have

  • 0

I have a map like this,

Map<Integer,ArrayList<Object>> myMap = new LinkedHashMap<Integer,ArrayList<Object>>();

Now I have to iterate this Map and then the ArrayList inside the map. How can I do this using JSTL?

  • 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-13T12:40:05+00:00Added an answer on May 13, 2026 at 12:40 pm

    You can use JSTL <c:forEach> tag to iterate over arrays, collections and maps.

    In case of arrays and collections, every iteration the var will give you just the currently iterated item right away.

    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    
    <c:forEach items="${collectionOrArray}" var="item">
        Item = ${item}<br>
    </c:forEach>
    

    In case of maps, every iteration the var will give you a Map.Entry object which in turn has getKey() and getValue() methods.

    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    
    <c:forEach items="${map}" var="entry">
        Key = ${entry.key}, value = ${entry.value}<br>
    </c:forEach>
    

    In your particular case, the ${entry.value} is actually a List, thus you need to iterate over it as well:

    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    
    <c:forEach items="${map}" var="entry">
        Key = ${entry.key}, values = 
        <c:forEach items="${entry.value}" var="item" varStatus="loop">
            ${item} ${!loop.last ? ', ' : ''}
        </c:forEach><br>
    </c:forEach>
    

    The varStatus is there just for convenience 😉

    To understand better what’s all going on here, here’s a plain Java translation:

    for (Entry<String, List<Object>> entry : map.entrySet()) {
        out.print("Key = " + entry.getKey() + ", values = ");
        for (Iterator<Object> iter = entry.getValue().iterator(); iter.hasNext();) {
            Object item = iter.next();
            out.print(item + (iter.hasNext() ? ", " : ""));
        }
        out.println();
    }
    

    See also:

    • How to loop through a HashMap in JSP?
    • Show JDBC ResultSet in HTML in JSP page using MVC and DAO pattern
    • How to loop over something a specified number of times in JSTL?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 516k
  • Answers 516k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The standard input is buffered. Your code will not see… May 16, 2026 at 6:41 pm
  • Editorial Team
    Editorial Team added an answer take out the GO statements and dump all the code… May 16, 2026 at 6:41 pm
  • Editorial Team
    Editorial Team added an answer Too late, but possibly somebody still need a solution. I've… May 16, 2026 at 6:41 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

If I have a Map like this: HashMap<Integer, ComparableObject> map; and I want to
Based on this question I have a couple of other questions: 1) the map
So I have a map: Map<String, Class> format = new HashMap<String, Class>(); And I
Let's say I have two same strings inside an ArrayList... is there a way
i am generating a chart map like this: http://chart.apis.google.com/chart?chs=440x220&cht=t&chco=CBD122&chld=US&chd=s:_&chtm=usa does anyone know if there
Let's say I have a class like this: public class Person { private String
I have a class Foo which overrides equals() and hashCode() properly. I would like
I have to map a set of known integers to another set of known
Let's say I have a LazySeq of java.lang.Character like (\b \ \! \/ \b
I'm working with a XML structure that looks like this: <ROOT> <ELEM_A> <A_DATE>20100825</A_DATE> <A_TIME>141500</A_TIME>

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.