Actually Sami is right--the value of the "integer" attribute on page 393 is an Integer *object* and even though it has an int value of 3, in this case, it is not coerced to the String value "3", so even if there WERE an attribute with the name "3", it wouldn't matter in this case.
So... the answer is still the same, but the reason is slightly different:
${requestScope[integer]...
Which becomes
${requestScope["3"]
Which becomes essentially null/zero in this case... Should really say;
${requestScope[integer]}
Which becomes
${requestScope[integer does not evaluate to a String so it makes no difference]}
Which becomes essentially null/zero!!
So... this kind of surprised me and if Sami hadn't tried this, I wouldn't have noticed...
Here's a little example you can do in
Tomcat;
<% Integer i = new Integer(3);
request.setAttribute("integer", i);
%>
${requestScope["integer"]} // returns 3--the value of the attribute, i, an Integer, is coerced to "3"
${integer} // also returns 3 for the same reason
${requestScope[integer]} // null -- without quotes, the value of the attribute is assumed to be the name of the attribute, BUT... it does not attempt to get a String value from the Integer object!
FYI--you won't have questions on the exam about this particular scenario.
Thanks Sami! Good
test... so now I know why I never explained this in the book...
And to Neil, you were still thinking about it in the right way, it's just that my explanation of the behavior for what EL thought was the actual value of [integer] was incorrect. It DID see [integer] and attempt to use the VALUE of that attribute as the *name* of an attribute, it did not see the value (an Integer object) as anything beyond an object... it didn't go through the extra steps of turning it into a "3".
Hope that makes sense still...
cheers,
Kathy