|
Val's Blog
Lots of stuff for Web 2.0 freaks and Javaholics
|
|
|
John F. Woods: "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." |
[ Login ] |
|
It is commonly admitted that dynamic languages are usually more flexible and permissible than static ones. On the other hand, another recognized fact about dynamic languages is that they provide more ways for you to write buggy software if you don't pay enough attention and don't play by the rules. For instance, I recently came across a nice bug in a web application making heavy use of Spring 2.0.2, JSP 2.0 and JSTL. Here is a piece of code that closely resembles the original code.
...
<%@ taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core' %>
<%@ taglib prefix='spring' uri='http://www.springframework.org/tags' %>
...
<ul>
<c:forEach items="${someValues}" var="value" varStatus="status">
<li>${status.index}. ${value}</li>
</c:forEach>
</ul>
...
<spring:bind path="address.zip">
<c:if test="status.error">
<c:out value="The ZIP code is not properly formatted." />
</c:if>
</spring:bind>
...
Can you spot it? Ok, it might not be immediately clear what the problem is, but remember that the JSP Expression Language is a dynamic language, and thus, variables are weakly typed. The problem lies around is the
Now the thing is that the javax.servlet.jsp.JspException: javax.servlet.jsp.jstl.core.LoopTagSupport$1Status
Very explicit as anyone can judge. In the end, the problem was that the first
For the record, the Spring 1.2.2 codebase used to explicitly cast the I hope this post will help other people not fall into the same nasty trap.
TrackBacks[0]
Comments[0]
Posted by val on May 20, 2008 2:58:07 PM CEST
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Content © Val | Powered by Pebble 1.9.1 |