Using this post I know that if a collection have only 1 value and that is string, then it is returned as String and not as Collection Object. My problem is that my collection can have anything ranging from Integer to BigDecimal to String returned in the collection. If I used below JSTL condition then it only catches the String type data. What about other types?
Here queryResults
contains List of array of Objects : List<Object[]>
. Therefore bookmark
should be array of Objects: Object[]
<c:forEach var="bookmark" items="${queryResults}" varStatus="loopStatus">
<tr class="${loopStatus.index % 2 == 0 ? 'roweven' : 'rowodd'}">
<c:choose>
<c:when test="${bookmark.getClass().simpleName == 'String'}">
<!--The collection has only 1 record and that is of type String. Can't run for loop. -->
<td><c:out value="${bookmark}"/></td>
</c:when>
<c:otherwise>
<!--The collection has more than 1 record therefore running a for loop. -->
<c:forEach begin="0" end="${fn:length(bookmark)-1}" varStatus="loop" >
<td><c:out value="${bookmark[loop.count-1]}"/></td>
</c:forEach>
</c:otherwise>
</c:choose>
</tr>
</c:forEach>