• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

EL question from Jdiscuss

 
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, that's probably a bug in the JDiscuss mock exam suite.
 
kapil munjal
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Kedar.
 
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even if it had been a Map, ${names.index} wouldn't have worked since it translates to ${names["index"]} instead of ${names[index]}.

-Yuriy
 
kapil munjal
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thats right Yuriy.
 
Crusading Chameleon likes the size of this ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic