Bug 8258

Summary: Core set action doesn't comply with the specification if the value attribute is null.
Product: Taglibs Reporter: Ryan Lubke <Ryan.Lubke>
Component: Standard TaglibAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: major    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Ryan Lubke 2002-04-18 15:45:02 UTC
Page 4-29 of the PFD, Null & Error Handling section

 - If value is null
     - Syntax 1 and 2, the scoped variable defined by var and scope is removed.

     - Syntax 3 and 4:
        - if target is a Map, remove the entry with the key identified by propery.
        - if target is a JavaBean, set the propery to null.

In Syntax 1 and 2,

var is not removed from scope, but appears to be set, at least in my case, to an
empty string ("").

<c:set var="test" value="test value"/>
<c:out value="${test}"/>
<c:set var="test" value="${null}"/>
<c:out value="${test}" default="Scoped variable properly removed"/>

The second c:out evaluates test as an empty string therefore the value
defined by the default attribute is not displayed.

This is true for syntax 2 as well.

In the case of a Map, setting the value to null doesn't remove the key
specified.

In the case of a JavaBean, the value is set to an emtpty string as well.
Comment 1 Shawn Bayern 2002-04-18 16:05:29 UTC
Thanks.  All the relevant code was already in place; it was just being occluded
by the fact that <c:set> is also specified to read its body.  (So the
bodyContent was coming through as "".)  I have fixed this to match the clear
intent of the spec and asked for a minor amendment to the spec to ensure the
behavior is unambiguous.  Ryan - please re-test just to be sure, since there are
lots of cases and I didn't walk through them all manually.  Thanks!