This section describes javax.servlet.jsp.tagext.IterationTag interface, which supports 3 event handlers using in the iteration tag lifecycle: doStartTag(), doAfterBody(), and doEndTag().
If you want to the javax.servlet.jsp.tagext.* package, you should starts with the
IterationTag interface. The BodyTag interface requires deeper knowledge of JSP in order to evaluate
the tag body properly.
Here is the list of methods required by
IterationTag interface and their calling conditions:
setPageContext(PageContext pc) - A help method, called before calling doStartTag()
to pass the PageContext object to the tag object.
setParent(Tag t) - A help method, called before calling doStartTag()
to pass the parent tag object to the current tag object, in case the current tag
is nested within another tag.
getParent() - A help method, called by child tag classes to access
grandparent tags.
doStartTag() - An interfacing point, called at the beginning of the process of the tag.
doAfterBody() - An interfacing point, called after processing the body.
doEndTag() - An interfacing point, called when ready to leave the process of the tag.
release() - An interfacing point, called before ending the process of the tag.
The steps used by the JSP tag extension facility to process a custom tag can be summarized
as follows:
Instanciating the tag object.
Calling setPageContext() and setParent() of the tag object.
Processing attributes of the tag. See my other notes on how attribute values are
passed to the tag object.
Calling doStartTag() of the tag object, which may return a flag to request for skipping
the body to perform a conditional body logic.
Processing the body of the tag.
Calling doAfterBody() of the tag object, which may return a flag to request for processing
the body again to perform a loop logic on the body.
Calling doEndTag() of the tag object.
Calling release() of the tag object.
The lifecycle of an IterationTag object can be illustrated as below: