File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Could we say that pageContext attributes have JSP servlet scope? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Could we say that pageContext attributes have JSP servlet scope?" Watch "Could we say that pageContext attributes have JSP servlet scope?" New topic
Author

Could we say that pageContext attributes have JSP servlet scope?

John Strong
Greenhorn

Joined: Jul 23, 2006
Posts: 13
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)
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

I think this is beyond the beginner level. Moving to the JSP forum.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60041
    
  65

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 ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Could we say that pageContext attributes have JSP servlet scope?
 
Similar Threads
scopes
page scope
DOUBT on a question JSP SCOPES
JSP implicit objects
pageContext why?