File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes EL problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "EL problem" Watch "EL problem" New topic

EL problem

Naresh Saw
Ranch Hand

Joined: Sep 03, 2005
Posts: 66

does EL throw ArrayIndexOutofBoundsException?
I m not getting this exception.

naresh<br />SCJP 1.4(86%), SCWCD 1.4(78%)
Chandra Atla
Ranch Hand

Joined: Jul 21, 2004
Posts: 91
Hi Naresh,

It will return "null" when an ArrayIndexOutOfBoundsException is thrown.

Here is an excerpt from EL chapter of JSP 2.0 spec..

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.
• If value-a is a Map, List, or array:
If value-a is a Map:
• If !value-a.containsKey(value-b) then return null.
• Otherwise, return value-a.get(value-b)
If value-a is a List or array:
• Coerce value-b to int (using coercion rules)
• If coercion couldn't be performed: error
• Then, if value-a.get(value-b) or Array.get(value-a, value-b) throws ArrayIndexOutOfBoundsException
or IndexOutOfBoundsException: return null
• Otherwise, if value-a.get(value-b) or Array.get(value-a, value-b) throws other
exception, error
• Otherwise, return value-a.get(value-b) or Array.get(value-a, value-b), as appropriate.
• 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.

Chandra Atla
I agree. Here's the link:
subject: EL problem
It's not a secret anymore!