Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
  • 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 ...
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

mistake in assesment exam?  RSS feed

Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The following question is from an scwcd assesment exam of a very large company we all know. I won't say who...

:::beginning of question::::
Given a JSP page with the line:

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

Which two occur? (Choose two.)
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.
C> The CustomerBean instance is populated with the values of the parameters in the request.
D> A CustomerBean instance is always created and stored in the session with the attribute name cust.
E> The CustomerBean identified by cust is located in the application and then stored in the session for later use.
::::end of question:::::

The answer they give is A and B. But I do not believe it is correct. I have tried to duplicate the behaviour myself and what I have found is if <jsp:useBean> includes the "type" attribute, and not the class attribute, a missing bean instance is NEVER created.

So I believe that only B is true.

Who is wrong? Me? Or this big company who I will not name?

Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I agree with you. I've tried that myself, it doesn't create a new bean.
There is also an excerpt from HFSJ:
'If type is used without class, the bean must already exist.
If class is used (with or without type) the class must NOT be abstract, and must have a public no-arg constructor.'
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!