It's not a secret anymore!
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes HFS: ambiguity in coffee cram ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "HFS: ambiguity in coffee cram ?" Watch "HFS: ambiguity in coffee cram ?" New topic

HFS: ambiguity in coffee cram ?

Neil Mc
Ranch Hand

Joined: Oct 20, 2003
Posts: 32

In the coffee cram for ch 8 question 11 (regarding the <jsp:useBean> std action) there seems to be an ambiguity...

Answer D is given as correct i.e. the statement... "Either the class or type attributes may be specified, but at least one" is given as true.

However, in the bullet point section (pg 414) it states that "the class attibute is optional" (and makes no mention of the type attribute). This makes sense as, in the case where the Bean already exists as an attribute, neither the class or type attributes are required - as the container does not need to create a new object.

The coffee cram answer and the bullet point seem to conflict with each other.

So, which is the case... is 'id' the only required attribute in <jsp:useBean> ?

Thanks for your time,

Colin Fletcher
Ranch Hand

Joined: Sep 10, 2004
Posts: 200

I understand the useBean attribute like this:

useBean id type|class ...

The attribute id is required.
Either the attribute type of class is required.

Do you know what the significance of using the type or class attribute is ?

SCJP 1.4 SCWCD 1.4
Neil Mc
Ranch Hand

Joined: Oct 20, 2003
Posts: 32
Yup - Polymorphic references.

The spec seems to say that class can only be ommitted if 'type' is included (i.e. and attribute already exists).

The bullet points on page 414 say "The 'class' attribute is optional". This isn't strictly true and is at best ambiguous on this point.
Kathy Sierra
Cowgirl and Author

Joined: Oct 10, 2002
Posts: 1589
Yes, the bullet point is ambiguous; you're right. While it is *true*--the attribute IS optional--as you said, it's only optional under the condition that "type" is supplied!

Good catch, and the early statement in the book is exactly how to interpret it (and folows the way it is described in the spec and the exam).

Neil Mc
Ranch Hand

Joined: Oct 20, 2003
Posts: 32
Again, thanks Kathy.

Don't think I've ever read a book where the authors are so readily on-hand to answer queries.

Top notch support
I agree. Here's the link:
subject: HFS: ambiguity in coffee cram ?
It's not a secret anymore!