Convert keys and values ​​from a HashMap to an HTML table with java


I have a HashMap which looks like the following:

HashMap<String, Integer> jcbs = new HashMap<String, Integer>();

The key is a String, the Value an Integer.

Now I have a html-file in which there is a table.

What I need to do now, is to fill all the keys and values of the HashMap into this html table.


    StringBuilder stringMapTable = new StringBuilder();

    Iterator it = jcbc.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry pair = (Map.Entry);
            stringMapTable.append("<tr><td>" + entry.getKey() + "</td><td>" +entry.getValue() + "</td></tr>");
            System.out.println(pair.getKey() + " = " + pair.getValue());
            it.remove(); // avoids a ConcurrentModificationException

  String mapTable = stringMapTable.toString();



<%=mapTable %>