I am no expert in JSP technology and looking for some help here to access HashMap from bean. I have a java class which returns a Hashmap, and would like to access both key and values of hash map in JSP. The following is what I tried
//jsp:
<jsp:useBean id="mc" class="MyMapClassReturnsMap" />
<c:forEach items="${mc.getMap()}" var="mapkeyval">
<tr>
<td><c:out value="${mapkeyval.key}"></c:out></td>
</tr>
</c:forEach>
//Error:
javax.el.PropertyNotFoundException: Property 'key' not found on type java.lang.String
page returning the map as String, if I remove .key from mapkeyval page displaying map as String. Not sure what I am missing, but any pointers would be appreciated gr8ly
I am sure I am returning HashMap from my class, following is my main method, which works as expected
HashMap<String, String> jname1 = new HashMap<String, String>();
..
..
public static void main(String[] args) {
MyMapClassReturnsMap ta = new MyMapClassReturnsMap();
ta.searchFiles("root","CUST");
for(Map.Entry<String, String> s: ta.jname1.entrySet())
System.out.println("HashMap Values : "+ s.getKey() + " :" +s.getValue());
}