You need to create a JSP that generates some JavaScript code to populate an array of strings
used on the client-side. Which JSP code snippet will create this array?
A.
MY_ARRAY = new Array();
<% for ( int i = 0; i < serverArray.length; i++ ) {
MY_ARRAY[<%= i %>] = ‘<%= serverArray[i] %>’;
} %>
B.
MY_ARRAY = new Array();
<% for ( int i = 0; i < serverArray.length; i++ ) {
MY_ARRAY[${i}] = ‘${serverArray[i]}’;
} %>
C.
MY_ARRAY = new Array();
<% for ( int i = 0; i < serverArray.length; i++ ) { %>
MY_ARRAY[<%= i %>] = ‘<%= serverArray[i] %>’;
<% } %>
D.
MY_ARRAY = new Array();
<% for ( int i = 0; i < serverArray.length; i++ ) { %>
MY_ARRAY[${i}] = ‘${serverArray[i]}’;
<% } %>
Explanation:
C
Maybe because i is neither an EL implicit object nor an attribute in any scope, so you can’t use i in EL expression