| Author |
About type and class attribute of jsp usebean
|
Swagato Bhatta
Ranch Hand
Joined: Nov 08, 2008
Posts: 72
|
|
But this is what I think about type and class
type =" myType" class ="myClass"
basically means
myType myBean= new myClass();
Please corret me anyone if I am wrong
I am just on slow/fast learning curve
|
Working on my SCWCD so I can be a J2EE consultant earning millions of dollars and showing everyone I can
|
 |
Pramod P Deore
Ranch Hand
Joined: Jul 15, 2008
Posts: 629
|
|
yes you are right
type==reference type
class==object type
|
Life is easy because we write the source code.....
|
 |
Swagato Bhatta
Ranch Hand
Joined: Nov 08, 2008
Posts: 72
|
|
Pramod P Deore wrote:yes you are right
type==reference type
class==object type
So was I right or wrong?
|
 |
Pramod P Deore
Ranch Hand
Joined: Jul 15, 2008
Posts: 629
|
|
yes you are right
type can store object of class.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56242
|
|
|
Almost. It's not always true that a new bean will be created.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Swagato Bhatta
Ranch Hand
Joined: Nov 08, 2008
Posts: 72
|
|
Bear Bibeault wrote:Almost. It's not always true that a new bean will be created.
Now I am confused. Example please
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56242
|
|
|
If a bean is already bound in the specified scope with the same name, it will be attached. A new bean is created only if one does not already exist.
|
 |
Swagato Bhatta
Ranch Hand
Joined: Nov 08, 2008
Posts: 72
|
|
Bear Bibeault wrote:If a bean is already bound in the specified scope with the same name, it will be attached. A new bean is created only if one does not already exist.
You mean the body of the useBean will be executed iff bean DOES NOT exist in the scope. Am I right?
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
Basically what Bear is saying is
Will not always mean
If there is a bean named whatever in page scope, then a new instance of myClass will not be created. Also the bean in the page scope might not be of type myClass...
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
Frits Walraven
Rancher
Joined: Apr 07, 2010
Posts: 1044
|
|
I think what Bear tries to say is that if the object is already in any scope, it will not be created with the jsp:useBean statement. Consequently if you have one or more jsp:setProperties as an body of the jsp:useBean (and the object is already in scope), those setters won't be called.
regards,
Frits
|
 |
 |
|
|
subject: About type and class attribute of jsp usebean
|
|
|