Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dought for EL in one mock exam its urgent

 
Praveena Chordia
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In mock exam there is following two question and answer which is given for these questions is contradictory .Please help me out for thia
1 Given the folowing code within a JSP page


<%
String [] noises = {"moo"};
request.setAttribute("noises",noises);
%>Which of the following will output the word
moo
in the page?


Choose at least one answer. A. ${requestScope.noises}
B. ${request.noises[0]}
C. ${request[noises["0"]]}
D. ${requestScope.noises['0']}
E. ${noises[0]}


Its answer is D,E

2nd question is


Given a JSP page that contains the following code?

<% java.util.ArrayList al = new java.util.ArrayList(); al.add("red"); request.setAttribute("al",al); java.util.HashMap hm = new java.util.HashMap(); hm.put("zero","red"); %>Which of the following will output the string
red

Choose at least one answer. A. ${al[0]}
B. ${al['0']}
C. ${hm["zero"]}
D. ${hm.zero}


anwer for this A and B in mock exam
explanation is "hm is not an attribute "
According to first answer it should be A,B,C,D
 
sudhakar karnati
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the first question answers are corect(D&E)..and for the second question also answers are correct because hashMap hm is created but it is not bound to the request scope..so answers A & B are correct..

i think you should not mention urgent when you make posts according to Javaranch policy..

Thanks & Regards,
Sudhakar Karnati
 
Praveena Chordia
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
Kram Nart
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the first question, 'request' does NOT exist in the EL space. Therefore, ruling those out.

For the second question, 'hw' is a hashmap variable declared in a scriptlet. EL does NOT see those at all. Therefore, ruling those out.

Hope that helps.
 
Vilas Lawande
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This means that "requestScope" is default implicit object in EL ?
 
Garlapati Ravi
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there is nothing called default implicit object in EL
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic