Wednesday, November 18, 2009

JSTL test condition and trailing spaces

Took me a few minutes to track this one down, but it did catch me by surprise. The trailing spaces in the test conditions for JSTL tags do make a difference. For those that are interested I was using Tomcat 6.

I was getting the following errors in my stacktrace:


An error occurred at line: 40 in the jsp file: /WEB-INF/jsp/genotypingInventory.jsp
The method setTest(boolean) in the type IfTag is not applicable for the arguments (String)
37:                     <td class="right-col">${sp.box.box }</td>
38:                     <td class="right-col">${sp.position }</td>
39:                     <td class="right-col">
40:                             <c:if test="${not empty sp.mouse.strain} ">
41:
42:                             </c:if>
43:                     </td>      


The error was in the line:


<c:if test="${not empty sp.mouse.strain} ">


The problem is the extra space after the end curly bracket. After changing it to the following it worked fine:



<c:if test="${not empty sp.mouse.strain}">

2 comments: