• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About type and class attribute of jsp usebean

 
Swagato Bhatta
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes you are right


type==reference type
class==object type
 
Swagato Bhatta
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes you are right

type can store object of class.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Almost. It's not always true that a new bean will be created.
 
Swagato Bhatta
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 9577
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2531
112
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic