Hello,
In jweb+ mock exams, there is one question on EL which is like
Consider the following code appearing in a
JSP file:
<%
request.setAttribute("names", new
String[]{ "A", "B", "C" } );
request.setAttribute("index", "1");
%>
<h1><!-- insert code here --></h1>
Which of the following statements will print B in inserted in the above JSP page?
Select 3 correct options
The answer listed are:
b ${names[1]}
c ${names.index}
d ${names[index]}
By the way the other options listed for this question are:
a ${names.1}
e ${names.$index}
f ${names[$index]}
Reading HFSJ, I thought ${name.index}, can be used only when the first attribute is a Map or a Bean and the second one after the . is a key in a Map or a property in a Bean. Further, I remember reading that for Array Lists, List etc the [] operator needs to be used.
Am, I misunderstanding some thing?
Thanks a lot
Siva