File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Bad answer in question in Sun preparation exam Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Bad answer in question in Sun preparation exam" Watch "Bad answer in question in Sun preparation exam" New topic
Author

Bad answer in question in Sun preparation exam

Iván Párraga
Ranch Hand

Joined: Dec 02, 2007
Posts: 54
Hi guys,

I'm having problems with this question:


Given a JSP page with the line:

<jsp:useBean id="cust" type="test.beans.CustomerBean" scope="session" />

Which two occur?


the preparation exam gives these two valid answers:


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.


As far as I know, A cannot be true because when not using class attribute in useBean tag, if the beans is not preinstantiated, the JSP NEVER tries to instantiate one. Am I missing some thing or this is definitively wrong?

Cheers,

Iv�n


Iván Párraga García
SCWCD 5, SCJD, SCJP 5, MySQL 5 DBA
Mamadou Touré
Ranch Hand

Joined: Dec 27, 2007
Posts: 189
You're right neither A nor B is correct


SCJP 5 (76%)
SCWCD 5 (86%)
SCBCD 5(70%)
--------------------
"The greatest glory in living lies not in never falling, but in raising every time we fall.".. Nelson Mandela
Justin Rundle
Ranch Hand

Joined: Mar 26, 2008
Posts: 123

From the JSP spec you can declare the type attribute on its own with <jsp:useBean> BUT the bean must exist otherwise it will throw a runtime exception so A is definitely wrong.
Christian Nicoll
Ranch Hand

Joined: Mar 09, 2008
Posts: 106
Answer A is not correct. Ivan has give the right reason for it.

I don't agree with Mamadou that Answer B is also not correct. I think that Answer B is correct, because I don't see any reasons why this answer shouldn't be correct.


SCJP 5, SCJD 5, SCWCD 5, SCBCD 5, SCJDWS 5
My SCBCD-Notes - My Hello World Webservice
Mamadou Touré
Ranch Hand

Joined: Dec 27, 2007
Posts: 189
Hi Folks,

Christian, You're right,

I've just re-read the answer B
B
The session is searched for a CustomerBean stored as the attribute name cust.


I missinterpreted the sentence, it's the CustomerBean which is searched and not a Session.

I apologize for the mistake
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Bad answer in question in Sun preparation exam