GeeCON Prague 2014*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes jsp:useBean tag question in mock exam 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 "jsp:useBean tag question in mock exam" Watch "jsp:useBean tag question in mock exam" New topic
Author

jsp:useBean tag question in mock exam

aanal jethalia
Greenhorn

Joined: Nov 16, 2006
Posts: 13
I came across the following question in the sun epractice exam:

Given a JSP page with the line:
<jsp:useBean id="cust" type="test.beans.CustomerBean" scope="session" />
Which two occur? (Choose two.)

A 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 A 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.

The correct answers stated are options A and B.

But I am doubtful about option A being correct. If we only use the "type" attribute and if the bean doesnot exist, does the container not throw an InstantiationException?

Please let me know if I this is the case. Thanks
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

The answer should be B alone. If only type is specified, the attribute better exist in the scope specified ( the default being page. ). If it does not exist then a runtime exception is thrown.


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
aanal jethalia
Greenhorn

Joined: Nov 16, 2006
Posts: 13
Cool....I am happy I was right....I found this question on one of the epractice exams I bought from sun's website...so had doubts about my understanding.....thanks for the confirmation
Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
yes, when only the type attribute is used, the thing named by it, must exist in the specified scope. and also, no bean will be created as you are not giving full information to the container i.e

type x = new class();

you are not telling the containr anything about the class,

hth


SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]
Performance is a compulsion, not a option, if my existence is to be justified.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp:useBean tag question in mock exam