So, I ended up using the “packages” available for i18n in the JSP as follows.
<fmt:message var="template" key="${animal.class.name}" />
with template.properties file
foo.bar.Animal = animal.jsp foo.bar.Cat = cat.jsp foo.bar.Dog = dog.jsp
So, the final solution will look like this:
<c:forEach var='animal' items='${animals}'> <span> <c:set var="animal" scope="request" value="${animal}"/> <fmt:message var="template" key="${animal.class.name}" /> <jsp:include page="${template}" /> </span> </c:forEach>
With template files that look like
Hello animal ${animal}! Hello cat ${animal}! Hello dog ${animal}!
source share