aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes HFS mock exam questions 9 and 17 - custom tag dev Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "HFS mock exam questions 9 and 17 - custom tag dev" Watch "HFS mock exam questions 9 and 17 - custom tag dev" New topic
Author

HFS mock exam questions 9 and 17 - custom tag dev

jean-francois lepetitj
Greenhorn

Joined: Sep 01, 2004
Posts: 4
Hi,
- In the question 9 p 563, I don't understand why the answer C is wrong :

Given:
10. public class BufTag extends BodyTagSupport {
11. public int doStartTag() throws JspException {
12. // insert code here
13. }
14. }
Assume that the tag has been properly configured to allow body content.
Which if inserted at line 12, would cause the JSP code
<mytags:mytag>BodyContent</mytags:mytag> to output BodyContent?

C. return EVAL_BODY_BUFFERED

- In the question 17 p 567, by reading the JSP v20 7.1.6 specifications one can understand that the B and D answers are wrong. But I haven't found in the HFS custom tag development chapter that, in case of simple Tag, the TLD <body-content> "JSP" value has to be forbidden. Indeed if this rule is mentioned for the Tag File on page 498 (through the tag directive), it seems that nothing is said about this shared behaviour due to the Simple Tag & Tag File comon origin : the Simple Tag Extension. But I haven't read yet all the book...

Anyway this book is realy great especially for french guys who can "joindre l'utile a l'agreable" by learning also US english frickin' expressions as :
Boom, Gee, Dude, Uh-oh, Um, Uh, Yikes, Crap
[ December 08, 2004: Message edited by: jean-francois lepetitj ]
Krzysiek Hycnar
Ranch Hand

Joined: Jan 02, 2004
Posts: 74
Hello Jean

>Hi,
>- In the question 9 p 563, I don't understand why the answer C is wrong :

>Given:
>10. public class BufTag extends BodyTagSupport {
>11. public int doStartTag() throws JspException {
>12. // insert code here
>13. }
>14. }
> more...



As for the first problem you mention, the answer is that if you return EVAL_BODY_BUFFERED you will not see the body content, because the EVAL_BODY_BUFFERED is a call for the containter to put the body in a BodyContent instance, which can be obtained later on when doAfterBody() is called. The problem is that in HFS (just a few pages before the mock exam) there's a picture that SUGGESTS that if you return EVEL_BODY_BUFFERED from doStartTag() the body will be evaluated (evaluated - to me it means that you will see the body content, or the output it produces) which is NOT TRUE because you must print the body contents yourself to see them.

You're not the only one who failed to answer this question anyway



>- In the question 17 p 567, by reading the JSP v20 7.1.6 specifications one >can understand that the B and D answers are wrong. But I haven't found in >the HFS custom tag development chapter that, in case of simple Tag, the TLD ><body-content> "JSP" value has to be forbidden. Indeed if this rule is >mentioned for the Tag File on page 498 (through the tag directive), it seems >that nothing is said about this shared behaviour due to the Simple Tag & Tag >File comon origin : the Simple Tag Extension. But I haven't read yet all the >book...


In the JSP pre 2.0 spec the default value for <body-content> was JSP and the common sense says, that it should remain true for the 2.0 spec as well (for backward compatibility). And it is. In the HFS the authors say (cannot remember the page #) that <body content> tag is mandatory, but they failed to add that it is mandatory only for Simple Tags, so if in a simple tag TLD description you don't specify it to be other than JSP (must be scriptless, empty or tagdependent) - it gets the default value... gues what?? (starts with J and is 3 characters long , and this in turn will blow up your page.


To the authors...

In the mock exam section (for the Custom Tag Developement) there are about 4 questions the reader has no chance to answer right based on the knowledge he/she gets from the chapter (ok.. there'are chances but they're described by probability calculus).

I may be wrong, but in the chapter on Custom Tag Developement (don't have the copy of the book with me right now )...

- <jsp:invoke> is never mentioned
- dynamic attributes (as well as DynamicAttributes interface) is never mentioned
- the fact that for every attribute in a tag file a page scoped variable is created is never mentioned
- the fact that not every directive that is legal in regular jsp pages is legal in tag files is never mentioned (I mean page - which is illegal in tag files)

All of the above listed facts are however mentioned in the mock questions for that chapter. I was bit confused to see them there, but hmmm.. maybe you just wanted to make us (the SCWCD candidates) start studying the specs or learn more.. you did it (at least in my case)

I also found some minor mistakes in the book. I'm now doing revision, and will try to gather them all and publish here for discussion - hope this helps to improve the quality of the book, which I think despite the mistakes is GREAT!!

Cheers
Chris
jean-francois lepetitj
Greenhorn

Joined: Sep 01, 2004
Posts: 4
Thank you very much Krzysiek* for your explanations.
For the question 9 p 563, the HFS page that you mentioned is p. 533.
So the same authors that you hail should have to fix it.

For all the other book errata there is the http://www.oreilly.com/catalog/headservletsjsp/errata/ html page.
So glance at it before publishing your discoveries.

However while reading this o'reilly errata page, some ambiguities stay.
Here is an example that I am just studying p 634 about <security-constraint> rules:

The book:
Hand written - if there were NO <http-method> elements, in the <web-resource-collection>, it would mean that NO HTTP Methods are allowed, by ANYONE in any role.
Key-point - if no HTTP Methods are specified then ALL Methods will be constrained.

Errata fix:
Hand written - if there are NO <http-method> elements, in the <web-resource-collection>, it would mean that ALL HTTP Methods are allowed, by ANYONE in any role.
Key-point - if no HTTP Methods are specified then ALL Methods are allowed.

Pretty different isn't it!

But NO new erratum has be written p 635 1 st paragraph for:
A resource is always constrained on an HTTP method by HTTP basis, although you CAN configure the <web-resource-collection> in such a way that ALL Methods are constrained, simply by not putting in ANY <http-method> elements.

So what is true!

Indeed is there a difference between
nothing and <http-method></http-method> (<http-method> does not seem to be a mandatory element),
as there is one between
nothing (all users are allowed)and <auth-constraint></auth-constraint> (no user is allowed)?

JF.


* Why Chris instead of Krzysiek or Krzys?
Nikhil Jain
Ranch Hand

Joined: May 15, 2005
Posts: 385
Hello there, I just just answering the Question 9 for custom tag. I am really confused with the explaining given for this topic & for the explaination given in HFS. If you read the table on page 546, (Key diff bet simple & classic tag). The category: "How to cause the body to be processed" says, Return EVAL_BODY_INCLUDE from doStartTag() or EVAL_BODY_BUFFERED if the calss implements BodyTag.

The question 9 implements the body tag & therefore the answer should be C.


SCJP 1.4, SCWCD 1.4, SCBCD 1.5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HFS mock exam questions 9 and 17 - custom tag dev
 
Similar Threads
Question from Head First book chapter 10
Doubt Qno-9 pno-563 HFS&JSP
HF Custom Tag question
Mock Exam: Head First 1.4 : Doubt
Custom Tags