• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doAfterBody() question

 
Terrence White
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On page 323 (Table 16.8, chaper 16) of the SCWCD Exam Study Kit, the author states that the EVAL_BODY_BUFFERED constant can be returned by doStartTag() and doAfterBody(), for tags that implement the BodyTag interface.
Is that really true?
I cannot find proof of this in the Servlet API nor the servlet spec.
From reading these, I am led to belive that only IterationTag.EVAL_BODY_AGAIN or Tag.SKIP_BODY can be returned by doAfterBody(), even when the tag implements the BodyTag interface. Am I correct?

I am studying for the 1.3 test, not the 1.4 beta, so I am only looking at version 1.2 of the JSP spec.
 
Edwin Keeton
Ranch Hand
Posts: 214
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the documentation for:
javax.servlet.jsp.tagext
Interface BodyTag
A tag handler that implements BodyTag is treated as one that implements IterationTag, except that the doStartTag method can return SKIP_BODY, EVAL_BODY_INCLUDE or EVAL_BODY_BUFFERED.
 
Edwin Keeton
Ranch Hand
Posts: 214
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I missed the second part of the question.
doAfterBody() is of course defined in the IterationTag interface and can return Tag.SKIP_BODY or IterationTag.EVAL_BODY_AGAIN.
BodyTag interface extends IterationTag and inherits the doAfterBody() method. The reason a tag implementing BodyTag can return BodyTag.EVAL_BODY_BUFFERED from doAfterBody() is that BodyTag.EVAL_BODY_BUFFERED is defined to have the same value (i.e., 2) as IteraionTag.EVAL_BODY_AGAIN. So in the context of BodyTag.doAfterBody() they mean the same thing.
The explanation is kind of messy, but the book is correct.
 
Terrence White
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for clearing that up for me.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic