Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Bad answer in question in Sun preparation exam

 
Ranch Hand
Posts: 54
  • 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
 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're right neither A nor B is correct
 
Ranch Hand
Posts: 123
Hibernate Spring Java
  • 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.
 
Ranch Hand
Posts: 132
  • 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
  • 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
 
Thank you my well lotioned goddess! Here, have my favorite tiny ad!
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic