Life cycle of JSP BodyTag interface

Previous article was about the life cycle of “Tag” interface, in this article i am going to explain the life cycle of “BodyTag” interface.

The BodyTag interface extends IterationTag by defining additional methods that let a tag handler manipulate the content of evaluating its body.

Life cycle of IterationTag and BodyTag interface in JSP
Life cycle of IterationTag and BodyTag interface in JSP


As per shown in Above figure, IterationTag extends Tag interface and adds one new method doAfterBody() that controls the reevaluation of its body.

doAfterBody() Process body (re)evaluation. This method is invoked by the JSP Page implementation object after every evaluation of the body into the BodyEvaluation object. The method is not invoked if there is no body evaluation.
If doAfterBody returns EVAL_BODY_AGAIN, a new evaluation of the body will happen (followed by another invocation of doAfterBody). If doAfterBody returns SKIP_BODY, no more body evaluations will occur, and the doEndTag method will be invoked.

In BodyTag, There is a new action method: doInitBody(), which is invoked right after setBodyContent() and before the body evaluation. This method is only invoked if doStartTag() returns EVAL_BODY_BUFFERED.

If EVAL_BODY_BUFFERED is returned, then a BodyContent object will be created (by code generated by the JSP compiler) to capture the body evaluation.

Example of Tag and BodyTag interface:
Tag Interface:

<up:userPicker multiSelect="true" />

BodyTag interface:

<up:userPicker multiSelect="true">
Select the User from UserPicker :
</up:userPicker>

Next article : How to Create JSP Custom Tag – using Tag interface or TagSupport

Posted

in

by

Tags:


Related Posts

Comments

3 responses to “Life cycle of JSP BodyTag interface”

  1. […] article : Life Cycle of JSP “BodyTag” interface. Sharevar dzone_url = "https://jitendrazaa.com/blog/java/life-cycle-of-jsp-tag-interface/&quot;; var […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Jitendra Zaa

Subscribe now to keep reading and get access to the full archive.

Continue Reading