Win a copy of Spring Boot in Practice this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

two useBean for the same id

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And you should also check the errata.
reply
    Bookmark Topic Watch Topic
  • New Topic