• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in Mock question

 
Gurukant Desai
Ranch Hand
Posts: 56
  • 0
  • Mark post as helpful
  • send pies
  • 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 ]
 
Vassili Vladimir
Ranch Hand
Posts: 1585
  • 0
  • Mark post as helpful
  • send pies
  • 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,
 
Kumar Garlapati
Ranch Hand
Posts: 38
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for the reply....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic