Hi,
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?
Options
Select 3 correct options.
1 ${names.1}
2 ${names[1]}
3 ${names.index}
4 ${names[index]}
5 ${names.$index}
6 ${names[$index]}
This question is taken from jdiscuss site and it gives 3 answers.
Answer - 2,3 and 4.
My confusion is 3rd option ${names.index}. I think it should not work as names is an array and '.' operator doesn't work with Arrays and List.
I have no idea why Enthuware termed it as correct.
Could someone help me out with this.
[ July 21, 2005: Message edited by: kapil munjal ]