I have a problem with some JSTL not evaluating a ‘gt’ as expected, some code:
<c:choose>
<c:when test="${param.totalPages > pageLinkCount}">
The JSP never renders the content of that when block, rather it always renders the block content. Something about the test is failing.
I tried a solution found here for a similar looking problem where the solution involved adding a declaration to tell JSP/JSTL engine that the vars are Longs (they are for me too)…
<%@ attribute name="currentPage" required="true" type="java.lang.Long" %>
… but I found that error:
org.apache.jasper.JasperException: /WEB-INF/jsp/includes/pagination.jsp(4,13) <%@ attribute directive can only be used in a tag file
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:132)
The test is in a JSP include included like this:
<jsp:include page="../includes/pagination.jsp" >
<jsp:param value="${pages}" name="totalPages"/>
....other params
Some test values output into the html:
param.TotalPages: 171
TotalPages: 171 (local JSTL var I tried assigning the value of param.totalPages)
Current: 64
BeginPage: 1
EndPage: 171
PageLinkCount: 3
I changed from the
style include to the
directive, changed the params to c:set var instead and now it seems to work.
So as much as I’d prefer to use jsp:include style of including pages it seems params are handled not quite as I expected so I’ll stick to @ directive style includes for now.