Issue
I didn't know how to iterate
My datatype is Multimap<String, AlbumAndAlbumType> in which the String holds the type of albums/which genre and the values consists the list of objects of type AlbumAndAlbumType
I retrieved data from db but I don't know how to iterate and display them in a jsp page.
the multimap returns as follows
{Kollywood Private Albums=[
AlbumAndAlbumType [album_id=48, album_name=Orasaadha, album_type_id=28, album_image=null, album_description=Orasaadha Private Album, language=TAMIL, type_name=Kollywood Private Albums, type_description=Kollywood Private Albums],.........
]}
the String (Kollywood Private Albums) is key and the values are list of objects of class type(AlbumAndAlbumType)
Here I want to display heading(h2) as key and iterate the values of that key and need to display all the album names(album_name) in heading(h4)
Solution
You can use <c:forEach..></c:forEach>
to iterate through your mutlimap .Suppose your multimap value is in some session attribute then do like below :
<%@ taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core" %>
<!--here "ses" is name of session attribute -->
<c:forEach var="entry" items="${ses.asMap()}">
<h2> <c:out value="${entry.key}"/></h2>
<br/>Values:
<c:forEach var="currentValue" items="${entry.value}">
<h4> <c:out value="${currentValue.album_id}"/> </h4>
<h4><c:out value="${currentValue.album_name}"/></h4>
//..so on
</c:forEach>
</c:forEach>
Answered By - Swati