Bug 36149

Summary: map keys are not consistently coerced
Product: Taglibs Reporter: Nick Padgett <nick.padgett>
Component: Standard TaglibAssignee: Tomcat Developers Mailing List <dev>
Severity: critical    
Priority: P1    
Version: 1.0.6   
Target Milestone: ---   
Hardware: All   
OS: All   

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

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


Now, if you try


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


This fails because 330707 is not a valid Java identifier.

Hope this helps,

    -- Pierre