With reference to the HF book, the answer to question 9 at the bottom of chapter 10 (page 553) looks incorrect to me. If you agree with the book, can you please post a better explanation? Thanks.
Given: 10. public class BugTag 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>
The book marks the correct answer to be B. return EVAL_BODY_INCLUDE; and tells you that option C is invalid because it directs the body of the tag to a buffer which the tag does not process. ??
However, since the class is extending BodyTagSupport, the correct answer should be: (ref to page 536) B. return EVAL_BODY_INCLUDE; C. return EVAL_BODY_BUFFERED;
Manikandan Jayaraman
Ranch Hand
Joined: Sep 15, 2004
Posts: 225
posted
0
Sandy, Not to worry!
In the real exam, you will have 'choose 1' (or) 'choose 2'.
Give first priority to EVAL_BODY_INCLUDE because that is simple to use.
However, if we use EVAL_BODY_BUFFERED, then we have to explicitly output the body content using writeOut and getEnclosingWriter methods.
But as you say, we can use both to output the body content.
Request the creation of new buffer, a BodyContent on which to evaluate the body of this tag. Returned from doStartTag when it implements BodyTag. This is an illegal return value for doStartTag when the class does not implement BodyTag.
Sayak Banerjee
Ranch Hand
Joined: Nov 28, 2006
Posts: 292
posted
0
Returning EVAL_BODY_BUFFERED won't print BodyContent to the output because this class only overrides the doStartTag() method and none of the rest....therefore the Question is perfectly alright [ December 28, 2006: Message edited by: Sayak Banerjee ]
Turn on, tune in, drop out.
Sandy Shah
Greenhorn
Joined: Dec 27, 2006
Posts: 2
posted
0
Thanks for those who responded and helped clarify the issue. I now have a better understanding of buffered body content.
Sandy
Renu Radhika
Ranch Hand
Joined: Oct 21, 2005
Posts: 243
posted
0
No Sayak.The class is extending BodyTagSupport and not BodyTag which will have the default implementation of setBodyContent(BodyContent b),so both should be fine right?
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.