| Author |
jsp:useBean type attribute problem
|
Rick Rangers
Ranch Hand
Joined: Feb 06, 2007
Posts: 47
|
|
Hi, I'm doing a test exam in preparation for my real exam next week and given the following snippet: <jsp:useBean id="cust" type="test.beans.CustomerBean" scope="session" /> The explanation of the question says that a CustomerBean instance is created if the attribute name cust is not found. My book (Deshmukh) says that if you only specify a type and an object cannot be located an InstantiatonException will occur. Which one is correct? Deshmukh makes more sence to me because if the type would be an interface then you can't instantiate an object, right?
|
SCJP 5.0<br />SCWCD 1.4<br />IBM Certified Associate Developer -- Rational Application Developer for WebSphere Software V6.0<br />IBM Certified Solution Developer - IBM WebSphere Portal V6.0
|
 |
Chaminda Amarasinghe
Ranch Hand
Joined: May 17, 2006
Posts: 402
|
|
Yes, you are correct. if useBean with type attribute the object (which set to id att.) must be in the specified scope. useBean with class att. creats a new object if that is not in the scope. You can test this by writng simple code.
|
 |
Chaminda Amarasinghe
Ranch Hand
Joined: May 17, 2006
Posts: 402
|
|
sorry, i made a mistake, the scope specifies where we create the new object.. but now i have a question, what is the usefullness of scope att. with type att. (without class att.)? because we cant create new object. so i think that is meaningless only type and scope atts. can other make clear this?
|
 |
Rick Rangers
Ranch Hand
Joined: Feb 06, 2007
Posts: 47
|
|
If you use both the type attribute and scope attribute you specify in which scope the bean referenced by a variable of type "type" should be searched.
|
 |
 |
|
|
subject: jsp:useBean type attribute problem
|
|
|