I would suggest using a tag file.
Create a tag file (e.g. /WEB-INF/tags/yesno.tag ) like this:
<%@ attribute name="value" type="java.lang.Boolean" required="true" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <c:choose><c:when test="${value}">yes</c:when><c:otherwise>no</c:otherwise></c:choose>
Then in your JSP:
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%> <tags:yesno value="${MyBoolean}"/>
The file tag is a bit bulky, but it is well encapsulated and reused.
source share