Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFSJ : page:553 Q:9

 
Sanjay pts
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

they said answer B
but i think answer C

Can anybody exapin me this please.

Thanx
sanjay
 
Vengan Krish
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Regards.
 
Sanjay pts
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.

Thanks
[ June 05, 2005: Message edited by: Narendra Dhande ]
 
osman cinar eren
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Yuriy Zilbergleyt
Ranch Hand
Posts: 429
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

-Yuriy
 
osman cinar eren
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
from the jsp spec 13.2.2 :

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 Reply
  • Bookmark Topic Watch Topic
  • New Topic