Bug 36149 - map keys are not consistently coerced
Summary: map keys are not consistently coerced
Status: RESOLVED INVALID
Alias: None
Product: Taglibs
Classification: Unclassified
Component: Standard Taglib (show other bugs)
Version: 1.0.6
Hardware: All All
: P1 critical (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-11 19:46 UTC by Nick Padgett
Modified: 2005-12-06 14:20 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Padgett 2005-08-11 19:46:01 UTC
When I create an entry in a map with the key 330707, it is interpreted as a 
String.  However, when I retrieve an entry in a map with the key 330707, it is 
interpreted as a Number.

<jsp:useBean id="franchiseShortName" class="java.util.HashMap" 
type="java.util.Map" />
<c:set target="${franchiseShortName}" property="${330707}" value="SLP" />
<c:out value="${franchiseShortName[330707]}" /> Doesn't Work!
<c:out value="${franchiseShortName['330707']}" /> Works!
Comment 1 Pierre Delisle 2005-12-06 23:20:07 UTC
Nick,

With the following statement:

  <c:set target="${franchiseShortName}" property="${330707}" value="SLP" />

The value ${330707} evaluates to an integer. However, the target
type for 'property' is a String. So the integer is converted to 
a String transparently.

This is why to retrieve the value, one must use the following
expression:

  franchiseShortName['330707']

Now, if you try

  franchiseShortName[330707]

this does not work because 330707 evaluates to an integer
that is boxed into an Integer, which does not result
as the key for any entry into the map.

And if you try

  franchiseShortName.330707

This fails because 330707 is not a valid Java identifier.

Hope this helps,

    -- Pierre