• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Dought for EL in one mock exam its urgent

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This means that "requestScope" is default implicit object in EL ?
 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
there is nothing called default implicit object in EL
reply
    Bookmark Topic Watch Topic
  • New Topic