Forums Register Login

Could we say that pageContext attributes have JSP servlet scope?

+Pie Number of slices to send: Send
In a regular servlet you can use attributes with request scope, session scope and application scope, but there doesn't seem to be anything like servlet scope. Correct? (Instance variables, presumably, could be considered to have "servlet scope" but there are servlet-scoped attributes).

However, isn't it true that pageContext attributes have JSP servlet scope? If so, then the JSP servlet would be the only type of servlet with servlet-scoped attributes.

I am trying to understand what is different about page context scope and request scope. At first, it seemed to me that JSP page scope and request scope ought to be the same thing, since a JSP corresponds to a request. But it occurs to me that you could do something like REFRESH THE JSP and that might give you two different requests within the same JSP page context.

If someone can provide other examples of cases where JSP scope is different from request scope, I'd be grateful.

Thanks, - John Strong (pluviosilla@gmail.com)
+Pie Number of slices to send: Send
I think this is beyond the beginner level. Moving to the JSP forum.
+Pie Number of slices to send: Send
 

Originally posted by John Strong:

If someone can provide other examples of cases where JSP scope is different from request scope, I'd be grateful.



A request can be forwarded to multiple resources and it will take its scoped variables with it.

If you are following accepted practices in modern web application design, a servlet controller is the first thing that will gain control when a request is made, and then, when any processing has been completed, forward to a JSP page to render the page view.

Request scope exists across both of these resources (the controller as well as the JSP), and is the customary means by which data is passed from controller to view. Page scope only exists during the execution of the JSP.

Also, page scope has ramifications when JSP include actions are used -- the parent and the included page each have their own page scope.

I would stop thinking in terms of a "servlet scope". It's not a concept that really exists and it will only serve to confuse you.
[ August 03, 2006: Message edited by: Bear Bibeault ]
We begin by testing your absorbancy by exposing you to this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1395 times.
Similar Threads
scopes
pageContext why?
JSP implicit objects
page scope
DOUBT on a question JSP SCOPES
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 23:07:04.