Meaningless Drivel is fun!
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes question of useBean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "question of useBean" Watch "question of useBean" New topic

question of useBean

Bess Moore
Ranch Hand

Joined: Jun 07, 2003
Posts: 45
<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?

Welcome to the real world, it sucks, but you're gonna love it !!!
Shrenik Sakriya
Ranch Hand

Joined: May 07, 2001
Posts: 40
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.

SCJP1.2 88%<br />SCWCD1.4 89%<br />CCNA 94%
Abhishek Sharma
Ranch Hand

Joined: Jan 09, 2006
Posts: 68
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".

madhav changala
Ranch Hand

Joined: Dec 20, 2005
Posts: 57
Yes above reply is correct.

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



Bess Moore
Ranch Hand

Joined: Jun 07, 2003
Posts: 45
the given answer is A & B. But i truly think that the correct answer is only B, just need confirmation.

thnaks guys
Seenikkannan krishnasamy

Joined: Jan 25, 2006
Posts: 15
it should be B only
Amirr Rafique
Ranch Hand

Joined: Nov 14, 2005
Posts: 324

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

"Know where to find the solution and how to use it - that's the secret of success."
Mark Beavis
Ranch Hand

Joined: Apr 07, 2005
Posts: 43
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?

I agree. Here's the link:
subject: question of useBean
It's not a secret anymore!