Bug 8258 - Core set action doesn't comply with the specification if the value attribute is null.
Summary: Core set action doesn't comply with the specification if the value attribute ...
Alias: None
Product: Taglibs
Classification: Unclassified
Component: Standard Taglib (show other bugs)
Version: unspecified
Hardware: All All
: P3 major (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2002-04-18 15:45 UTC by Ryan Lubke
Modified: 2004-11-16 19:05 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
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

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!