<%@ page import="java.util.*" %> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/ea/core" %> JSTL: EcmaScript EL Support -- Simple Array Access Example

Array Access

EcmaScript uses the [] notation to access array elements. If the first operand is an array then the second operand (the one that goes between the brackets) should be an expression that evaluates to an integer. If the first operand is a reference to an object then the second operand should be an expression that evaluates to a string that names a property of the object.

Here is an example:

Favorite Actor and Role

<% request.setAttribute("myArray", new String[] {"Harrison", "Ford", "Indiana", "Jones"}); %> <%-- demonstrating how to use expression to get index --%> <%-- demonstrating how to use status object to get index --%>
Array Index Value
Array[]