File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bad answer in question in Sun preparation exam

 
Iván Párraga
Ranch Hand
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mamadou Touré
Ranch Hand
Posts: 189
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're right neither A nor B is correct
 
Justin Rundle
Ranch Hand
Posts: 123
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 106
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mamadou Touré
Ranch Hand
Posts: 189
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic