Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question of useBean

 
Bess Moore
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<jsp:useBean id="cust" type="test.beans.CustomerBean" scope="session" />

Which two occur? (Choose two.)

A CustomerBean instance is created if the attribute name cust is not found.

B The session is searched for a CustomerBean stored as the attribute name cust.

C The CustomerBean instance is populated with the values of the parameters in the request.

D CustomerBean instance is always created and stored in the session with the attribute name cust.

E The CustomerBean identified by cust is located in the application and then stored in the session for later use.

any idea?
 
Shrenik Sakriya
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The First 2 Options (A,B) are correct. The CustomerBean instance is looked for in the session with the attribute "cust" & If it doesn't exist then a new one will be created.
 
Abhishek Sharma
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well no doubt B is a correct option but regarding statement

& If it doesn't exist then a new one will be created.


I am agree with this as this condition is true with "class" attribute of usebean not with "type".


Thanks
Abhishek
 
madhav changala
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes above reply is correct.

My answer is only B.. no other options..


Regards

Madhav
 
Bess Moore
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the given answer is A & B. But i truly think that the correct answer is only B, just need confirmation.

thnaks guys
 
Seenikkannan krishnasamy
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it should be B only
 
Amirr Rafique
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Above statement will look for CustomerBean object in session stored against id cust. If not found it will create one.



It will try to locate CustmerBean insession against id cust and it will use type value as reference of the object in generated servlet. For the above statement the object must be in scope else it will generate error (it will not create new object).


For this statement it will try to locate CustomerBean object in mentioned scope and if not found it will create new object and store it in mentioned scope.

Guys I am doubted about last statement. Please confirm
 
Mark Beavis
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with you Bess - I think only (B) is correct.

If you refer to HFSJ pg 354 then when <jsp:useBean> is used with the "type" attribute then the object must already exist, otherwise an InstantiationExeption with occur.

My question is like yours - what is the other correct answer?

where did you find this question?

Thanks
Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic