Can someone help on how to display a TreeMap<String, Stats> in a JSP using JSTL?
I am trying to display all the records in a table in the JSP Page.
Can someone help on how to display a TreeMap<String, Stats> in a JSP using JSTL?
I am trying to display all the records in a table in the JSP Page.
 
    
     
    
    something like this
<c:forEach items="${map}" var="entry">
    ${entry.key} ${entry.value.myProperty}
</c:forEach>
The object value for each of map's entry is referenced as "${entry.value}" and java bean properties in this object will be accessed as ${entry.value.myProperty} where by "myProperty" is readable property on that bean and hence must have a getMyProperty() method in that bean class.
 
    
     
    
    Something like this:
<%
for (Map.Entry<String,Object> entry : map.entrySet()) {
    String key = entry.getKey();
    Object o = entry.getValue();
%>
out.println(o);
<%
}
>%
 
    
     
    
    You may try something like -
Iterator<String> = treeMap.keySet().iterator();
PrintWriter out; // out has defined somewhere, may be something else
while(iterator.hasNext()) {
     key = iterator.next();
     out.println(key + " --- " + treeMap.get(key));
     // you can add you html code to suit your needs
}
Hope this help
 
    
    Okay after some trails this is how we do it.
<c:forEach items="${treemap}" var="treemap">
<tr >
<td>${treemap.key}</td>
<td>${treemap.value.varNamefromyourPOJO}</td>
</tr>
</c:forEach>
