public class bufTag extends BodyTagSupport { public int doStartTag() throws JspException { //INSERT CODE HERE } }
Assume that tag has properly Configured to allow body-content. Which,if inserted at line // would cause jsp code <mytags:mytag>BodyContent</mytags:mytag> to output bodyContent?
A. return SKIP_BODY; B. return EVAL_BODY_INCLUDE C. return EVAL_BODY_BUFFERED D. return BODY_CONTENT
Answer B is correct. Only when you return EVAL_BODY_INCLUDE your body will be processed. You return EVAL_BODY_PROCESSED when you need access to the body for your own manipulation. Check out the lifecycle chart on HFS page 533.
You return EVAL_BODY_BUFFERED when you need access to the body for your own manipulation.
I read the same but can u plz tell me which kind of our own manupulations???.. Can u plz expain it me in detail with example Help will be appriciated. Thanx in advance sanjay
If we return EVAL_BODY_BUFFERED, a new buffer, an instance of body BodyContent is created and is available for further processing. we can simply get writer from the BodyContent object and print the content or make chages in the content.
I guess both B and C are correct. If you look at the process diagram on page 533, with EVAL_BODY_BUFFERED, after the 2 methods are called, the body is evaluated.
As I understand it, C (EVAL_BODY_BUFFERED) is not really a correct answer because while it might output the body, that really depends on the code written to process the body. And if you go through the extra effort to write that code, chances are you're not going to just take the body and dump it into the output without at least some filtering.
If EVAL_BODY_BUFFERED is returned, and the custom action element is not empty, setBodyContent() is invoked, doInitBody() is invoked, the body is evaluated, doAfterBody() is invoked, and then, after zero or more iterations, doEnd- Tag() is invoked. If the custom action element is empty, only doStart() and doEndTag() are invoked.
Post by:autobot
Are you okay? You look a little big. Maybe this tiny ad will help:
a bit of art, as a gift, that will fit in a stocking