Thanks & Regards
SCJP, SCWCD
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Thanks & Regards
SCJP, SCWCD
Thanks & Regards
SCJP, SCWCD
Deep Gagan wrote:Also can you please get this to writer's notice that this info is wrong in the book, so that they can correct in the next version.
[My Blog]
All roads lead to JavaRanch
JSP.2.3.4
expr-a.identifier-b is equivalent to expr-a["identifier-b"]; that is, the identifier
identifier-b is used to construct a literal whose value is the identifier, and then the []
operator is used with that value.
To evaluate expr-a[expr-b]:
Evaluate expr-a into value-a If value-a is null, return null. Evaluate expr-b into value-b If value-b is null, return null.
Frits Walraven wrote:That is however different from ${bar[foo]}.
${bar[foo]} can be used for beans as well
JSP.2.3.4
.....[removed]
Otherwise (a JavaBeans object), coerce value-b to String
-If value-b is a readable property of value-a, as per the JavaBeans specification:
If getter throws an exception: error Otherwise: return result of getter call
-Otherwise: error.
Conclusion: no mistake in the the book.
bar["foo"] will throw an exception but NOT bar[foo]