• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubts in given answers..

 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ranchers

please check the 14th question pg no. 586 , chapter 10.

14th Question

Which are valid method calls on a pageContext object?
A. getAttributeNames();
B. getAttribute("key");
C. findAttribute("key")
D. getSessionAttribute()
E. getAttributeScope("key")
F. findAttribute("key","pageContext.SESSION_SCOPE")
G. getAttribute("key","pageContext.SESSION_SCOPE")

Given answers: B, C, E, G. which state that getAttributeScope("key") is the valid method call.

I have not seen or notice this method on the pageContext API shown in the HFSJ book

please correct me if I am wrong.
 
swati bannore
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

E. getAttributeScope("key")

The correct method is getAtrributesScope(String var) ,

Have a look here -
http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/jsp/PageContext.html#getAttributesScope(java.lang.String)
 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Swati for your reply, so the method name is listed in this question is wrong. And if so then why this option is included in the answer given.


Please help
 
Vijitha Kumara
Bartender
Pie
Posts: 3930
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How come this is true?

G. getAttribute("key","pageContext.SESSION_SCOPE")


I guess it's a typo as scope argument should be an int.
 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess it's a typo as scope argument should be an int.


the method argument to scope is an int Constant
 
Vijitha Kumara
Bartender
Pie
Posts: 3930
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Poonam Agarwal wrote:
I guess it's a typo as scope argument should be an int.

the method argument to scope is an int Constant


So, the option G to be a correct one it should be,

G. getAttribute("key",pageContext.SESSION_SCOPE)


You have quotes around the pageContext.SESSION_SCOPE in your original post.
 
swati bannore
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Poonam,

Check the errata for the edition you have. I have the latest HFSJ and it is CORRECTLY defined as

E.getAttributesScope("key")

Hope this solves the confusion. And yes, in the exam,if its mis-spelled, dont select it
 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Swati
 
ankit kumar
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which are valid method calls on a pageContext object?
A. getAttributeNames();
B. getAttribute("key");
C. findAttribute("key")
D. getSessionAttribute()
E. getAttributeScope("key")
F. findAttribute("key","pageContext.SESSION_SCOPE")
G. getAttribute("key","pageContext.SESSION_SCOPE")


There is already getAttributesScope("key") in the HFSJ book . if You have the latest book of that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic