0 votes
1 view
in Java by (4.1k 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 (46.1k 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 Sep 10, 2019 in Java by Nigam (4.1k points)
0 votes
1 answer
asked Sep 30, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
asked Nov 25, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...