How would you properly render a list of objects in jsp with differing types? Say, for example, I have to render these different objects in a specified order.
One way could be to use a common type variable or instanceof but that means having a big switch/if statement to manage them all:
<c:forEach var="o" items="${bigListofObjects}" >
<c:choose>
<c:when test='${o.type=="simple"}' >
<!-- render simple -->
</c:when>
<c:when test='${o.type=="complex"}' >
<!-- render complex -->
</c:when>
<!-- etc etc ... -->
</c:choose>
</c:forEach>
I could add a render() method to each class but then that means mixing the view with the rest of the code.
What happens if I want to render another type later on? Is there something I could do with custom jsp tags?