Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

about pageContext.findAttribute("param")  RSS feed

 
Himai Minh
Ranch Hand
Posts: 1572
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For mock exam question 12 of Ch 10 in Head First book,

Option C is invalid because an attribute in page scope would be found before checking request scope.
C. String p = pageContext.findAttribute("param");


When I try it, it works with a type cast:
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Posts: 3013
236
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it works, but it is not guarenteed to be the value of the request-scoped attribute as required by the question. If there is an attribute with the same name "param" in the page-scope it will be assigned to p instead of the request-scoped variable.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!