aspose file tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes About type and class attribute of jsp usebean Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "About type and class attribute of jsp usebean" Watch "About type and class attribute of jsp usebean" New topic
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
    
  13

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
    
  13

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
    
    2

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About type and class attribute of jsp usebean
 
Similar Threads
difference between instantion and object.
Generics version of "new T()"?
finalize() method
superclasses- initializing it's fields in the subclass
Polymorphism