Friday, February 03, 2006

JSTL pointers?

Here's one that can be useful. I created a HashMap of HashMaps (formFields). Each HashMap in the HashMap contains some data about a formfield. I noticed that depending on how I access the inner HashMaps, it either acts like call by value or call by reference. This is under Sun Appserver 8.1.

<c:forEach var="field" items="${formFields}">
<%-- this creates a copy --%>
<c:set var="currentField" value="${field.value}"/>
<%-- this creates a pointer: --%>
<c:set var="currentField" value="${formFields[field.key]}"/>
</c:forEach>

No comments:

Labels

Blog Archive

Contributors