wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Question about page scope and implicit object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Question about page scope and implicit object" Watch "Question about page scope and implicit object" New topic
Author

Question about page scope and implicit object

Edwin Wong
Greenhorn

Joined: Apr 15, 2001
Posts: 10
Hi all
I have a question about scope in JSP
When I type
<jsp:useBean id="hello" class="ABC"/>
I know that the default scope is "page".
Therefore, it is no doubt that I can use all the implicit objects in this scope.
However, (1)I can still use the implicit object "application" without specify the scope ="application" (2) I can't use the implicit object "session" without specify scope="session"
I got th following observation:
1) scope="page" , all page implicit object + "application"
2) scope="session", ?
3) scope="application", ?
4) scope="request" ?
Please correct me if I make any mistake
I am using Tomcat 4.0
Many thanks
Edwin
[ April 03, 2002: Message edited by: Edwin Wong ]
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
The scope of a bean is different from implicit objects. There is no relation between declaring the scope of an object and the use of implicit objects (well, ofcourse other than they share they same name unfortunately).
When you specify a scope for a bean, the bean is now associated to that "scope". But this has nothing to do with wether you can access the implicit objects in a JSP or otherwise.
regds.
- satya


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
tony lee
Ranch Hand

Joined: Jan 21, 2002
Posts: 52
Hi,
What does a scope mean then
Not a specific range of data's accessibility?
For example, a variable defined in request scope has not any intervention from request to request, but a variable in session scope does.


SCJP2, SCWCD
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Therefore, it is no doubt that I can use all the implicit objects in this scope.

Implicit objects have clearly defined scopes (see JSP.2.8.3 Implicit Objects of the JSP 1.2 specs), although they can be made unavailable by a page directive.
There is no relation between declaring the scope of an object and the use of implicit objects (well, ofcourse other than they share they same name unfortunately).

What satya was trying to say is that, for example, the identifier session inside a JSP may either mean:
(a) a value for the scope attribute in a <jsp:useBean> tag, or
(b) the session implicit object
which are two different things, although, of course, the implicit object session is of session scope (that should have naturally implicit ).
-anthony
Edwin Wong
Greenhorn

Joined: Apr 15, 2001
Posts: 10
Dear all
Thanks for all your reply !
After I have read the specification of JSP carefully, I got a new picture. I understand the scope of useBean tag is not related to the implicit objects. sorry
As Madhav said, unfortunately they use the same name. I found the step for instant a JSP tag in the following url :
http://java.sun.com/products/jsp/tags/10/syntaxref10.fm14.html
According to the above url:
----------------------------------
The <jsp:useBean> tag attempts to locates a Bean, or if the Bean does not exist, instantiates it from a class or serialized template. To locate or instantiate the Bean, <jsp:useBean> takes the following steps, in this order:
1)Attempts to locate a Bean with the scope and name you specify.
2)Defines an object reference variable with the name you specify.
3)If it finds the Bean, stores a reference to it in the variable. If you specified type, gives the Bean that type.
4)If it does not find the Bean, instantiates it from the class you specify, storing a reference to it in the new variable. If the class name represents a serialized template, the Bean is instantiated by java.beans.Beans.instantiate.
5)If it has instantiated (rather than located) the Bean, and if it has body tags (between <jsp:useBean> and </jsp:useBean> , executes the body tags.
----------------------------------
The scope in useBean tag is used for locate bean only
Cheers
Edwin
[ April 04, 2002: Message edited by: Edwin Wong ]
[ April 04, 2002: Message edited by: Edwin Wong ]
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
FYI the base url for the syntax reference is http://java.sun.com/products/jsp/tags/10/tags.html
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Question about page scope and implicit object
 
Similar Threads
JSP page object
Page scope object
jsp scope problem
page scope
question about page scope