Monday, July 18, 2011

JSTL Gotcha

Why doesn’t this work?


<%@ taglib uri="http://stripes.sourceforge.net/stripes.tld" prefix="stripes" %>
<%@ taglib uri="http://www.stripes-stuff.org/security.tld" prefix="security" %>
<%@ taglib uri="http://stripes.bge.ie/StripesExtension.tld" prefix="stripes-extension" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>


<c:set var="a" value="A"></c:set>
<c:set var="b" value="B"></c:set>
<c:set var="c" value="C"></c:set>

<c:if test="${a=='A' }">
a= A,
<c:if test="${b=='B' } ">
b=B
<c:if test="${c=='C' }">
c=C
</c:if>
</c:if>
</c:if>

The answer is the space in the test B jstl tag.

Another few hours of my life wasted...
Also another time waster... Beware of <div id=”myDiv” class=”myDiv” />

Firefox didn’t like the autoclose tag. I needed to explicitly add a </div>

No comments: