• 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

Doubt in Mock question

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I found this question in Marcus Green's mock exam paper-1.

52. Given a JSP page with the following code, which of the following options would result in the output of red?

<%
java.util.HashMap hm = new java.util.HashMap();
hm.put("apple","red");
request.setAttribute("apple",hm);
%>Choose at least one answer.
a. ${apple.["apple"]}
b. ${apple.apple}
c. ${apple["apple"]}
d. ${apple['apple']}

Correct answers given are b,c and d.
I have a doubt, whether requestScope's attribute "apple" can be accessed directly by name?
I think this question is wrong. Please confirm.

[ May 06, 2008: Message edited by: Gurukant Desai ]
[ May 06, 2008: Message edited by: Gurukant Desai ]
 
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean by : can be accessed directly by name?

You are already using its name to access it!

Please explain the meaning of your question.

Regards,
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


There is nothing wrong in the question, its absolutely correct.
we can access all scope attributes directly.



all the above can access directly using b,c and d options.
 
Gurukant Desai
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for the reply....
 
reply
    Bookmark Topic Watch Topic
  • New Topic