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 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

Related Questions

I have a Hashmap in Java like this: private Map<String, Integer> team1 = new
I have something like this: Map<String, String> myMap = ...; for(String key : myMap.keySet())
We have several areas where code like this can be seen public Map extractData(ResultSet
If I have a Map like this: HashMap<Integer, ComparableObject> map; and I want to
I have a a map that looks like this: public class VerbResult { @JsonProperty("similarVerbs")
I have a map array with objects stuffed with variables looking like this: var
I have a Map that uses a Set for the key type, like this:
I have something like this: [{'date': 1, 'value':5}, {'date':2,'value':3}, ...] and want to map
I have a class like this: class MyClass{ public: MyClass(int Mode); private: std::map <
I have a recursive data type like this: template<typename T> struct SomeType { std::map<T,

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.