Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

two useBean for the same id

 
Matteo Palmieri
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, at page 344 of the "Sun Certified Web Component Developer Study Companion" from Charles Lyons
can be found this question:

What is the difference between the following two tag declarations ?

(A) There is no difference; these are identical statements
(B) The first statement instantiates a new instance if one isn't available in the scoped attribute, while the second throws a runtime exception.
(C) The first statement tries to retrieve the object from serialised form before instantiating a new instance.
(D) The second statement tries to retrieve the object from serialized form before instantiating a new instance.
(E) The first statement sets the JSP scripting variable called user while the second does not.

The given answer is (D). My questions are:
1) I know that the beanName attribute should be used together with the type attribute, so (D) should not hold true...
2) What is supposed to be the containers behaviour when two jsp:useBean are used on the same page referring to the same id ?

Thanks in advance for your help
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) You're right
2) This question is not about beans declared in the same page. But if it happened to be, it would not be valid. Beans must be identified with different ids. Duplicate ids in the same translation unit will cause an error.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And you should also check the errata.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic