Have I stumbled upon the next tutorial of JSP tricks to simplify template creation? to use JSP to create page templates (how have I missed this for so long?!?), however after some searches I canβt figure out how (or if possible) to check if the JSP fragment is installed.
Here is an example of what I'm trying to do:
I have a template called default.tag
. It has 2 JSP attributes defined as follows:
<%@attribute name="title" fragment="true" required="true" %> <%@attribute name="heading" fragment="true" %>
Then in the page code, I have a page <title>
element set to <jsp:invoke fragment="title" />
. Then, later on the page, I have the following:
<c:choose> <c:when test="${true}"> <jsp:invoke fragment="heading" /> </c:when> <c:otherwise> <jsp:invoke fragment="title" /> </c:otherwise> </c:choose>
Where I have <c:when test="${true}">
, I want to check if the heading
fragment was set to display it, but if not, the title
fragment is used by default.
jsp
Jared
source share