File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about implicit JSP objects

 
Timber Lee
Ranch Hand
Posts: 157
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the following implicit JSP objects have page scope?
A request
B response
C config
D pageconfig
 
Marcelo Sousa Ancelmo
Ranch Hand
Posts: 498
Eclipse IDE Fedora Firefox Browser
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
request - request scope > false
response - page scope > true
config - page scope > true
pageconfig - there is no pageconfig implicit object > false
So right answers are B and C
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am I the only one who has problems understanding questions such as this, and the precise concept of "scope" in this context? The problem is not a lack of knowledge about the internals of servlets and JSPs -- I know perfectly well what each of these objects do -- but about semantics: what does "scope" mean exactly?
For JavaBeans, "scope" is well defined. A bean is generally either a ServletContext attribute, a ServletRequest attribute, or a PageContext attribute. Implicit objects are less straightforward though.
Like the "request" object, the "response" is with us for the entire duration of the request, so arguably it has request scope. The specification says "page scope", though, so page scope it is.
The request (like the response) may be hidden behind wrappers for part of its lifetime; does that affect its "scope-ness" in this question? Clearly not not. The spec says it's request scope.
Apparently the determining factor for "scope-ness" is where we can find the implicit object in question. The response is page scope because we can find it in the PageContext object. But wait a minute, we can find the request there as well! And there is no "getRequest()" method anywhere else! But Sun obviously decided that "request" being page scope would be nonsensical. To be honest, you can make a very good case that "response" being considered page scope is just as nonsensical.
So I'm reduced to merely learning by rote how the specification defines the scope, without that adding anything to my actual knowledge or helping me in any way to do my job
Can anyone make more sense of this?
- Peter
 
Frosty One
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have taken several of the practice tests in the Manning SCWCD and the one topic I have had difficulty getting a grasp on is the concept of JSP scopes and how they relate to the implicit variables and Objects. It seems to make sense : application=ServletContext is Application scope, session=HttpSession is session scope, request=ServletRequest is request scope; I think page scope is the confusing one. Any simple rules to live by for page scope?
 
Marcelo Sousa Ancelmo
Ranch Hand
Posts: 498
Eclipse IDE Fedora Firefox Browser
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yourself responded your question, you said that:
application=ServletContext is Application scope, session=HttpSession is session scope, request=ServletRequest is request scope

So, anything different from this is page scope, i.e: response, out, config, page, pageContext and exception.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic