Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (4k points)

How can I loop through a HashMap in JSP?

<%

    HashMap<String, String> countries = MainUtils.getCountries(l);

%>

<select name="country">

    <% 

        // Here I need to loop through countries.

    %>

</select>

1 Answer

0 votes
by (46k points)

Depending on what you want to accomplish within the loop, iterate over one of these instead:

  • countries.keySet()
  • countries.entrySet()
  • countries.values()

Related questions

0 votes
1 answer
asked Jul 27, 2019 in Java by Ritik (3.5k points)
0 votes
1 answer
asked Nov 25, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
asked Sep 30, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
asked Sep 10, 2019 in Java by Nigam (4k points)
0 votes
1 answer

Browse Categories

...