The value of an array property index can also be set from a page parameter. For example, if a JSP has the page parameter latestHobby and it contains an integer value, the JSP can use that parameter as an index into the array property Student_01.hobbies:

<dsp:valueof bean="Student_01.hobbies[param:latestHobby]"/>

As with properties, you can also use EL to express the page parameter as an array index. The previous example might be modified as follows:

<dsp:getvalueof param="latestHobby" var="hobby"></dsp:getvalueof>

<dsp:param name="latestHobby" value="3"/>
<dsp:valueof bean="Student_01.hobbies[${hobby}]"/>

Note: While you can use a parameter as an array index, a parameter cannot itself be indexed.

loading table of contents...