• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Two Questions on BodyTag interface

 
viswanath sastry
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These are the two questions i have on implementing BodyTag Interface
1.Say,iam implementing BodyTag Interface,
and in my doStartTag() method, I return
EVAL_BODY_BUFFERED.Now, when the doAfterBody() method is called, will there be *any* difference if I return EVAL_BODY_AGAIN or EVAL_BODY_BUFFERED?will one effect Buffering and the other not?any such difference?
2.when implementing BodyTag Interface,if I have the following in doStarTag()/doEndTag()/doAfterBody() methods
case 1: pageContext.getOut().print("how are you?");
case 2: JSPWriter out = bodyContent.getEnclosingWriter() ;
out.print("how are you?") ;
bodyContent.writeOut(out);
Is there any difference in case 1 and case 2? Is it like in the first case iam writing to output directly instead of buffer and in the second case iam writing to buffer?and where does getPreviousOut() method come into picture?
Thanks to all.
 
Andres Bonifacio
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. I don't think there is a difference. Because by reflection the container knows that your tag handler implements the BodyTag interface thus the output will be buffered. And besides both fields have the same value of 2.
2.
case 1. I would think that you are writing directly to the output stream of the response.
case 2. Provided that you return a EVAL_BODY_BUFFERED on doStartTag(). I'm pretty sure that your output is buffered first because BodyContent extends JspWriter and all the print and write methods are overriden so that any data sent will be buffered first.
Good questions BTW.
 
viswanath sastry
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Andres,
In the second question, i was actually trying to ask....
if i return EVAL_BODY_BUFFERED on doStartTag() and use the two cases given, in doStarTag()/doEndTag()/doAfterBody() methods,
Is there any difference in case 1 and case 2? Is it like in the first case iam writing to output directly instead of buffer and in the second case iam writing to buffer?and where does getPreviousOut() method come into picture?
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic