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
grand parent 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
- 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:
Last update: 2012.
Table of Contents
About This Book
JSP (JavaServer Pages) Overview
Tomcat 7 Installation on Windows Systems
JSP Scripting Elements
Java Servlet Introduction
JSP Implicit Objects
Syntax of JSP Pages and JSP Documents
JSP Application Session
Managing Cookies in JSP Pages
JavaBean Objects and "useBean" Action Elements
Managing HTTP Response Header Lines
Non-ASCII Characters Support in JSP Pages
Performance of JSP Pages
EL (Expression Language)
Overview of JSTL (JSP Standard Tag Libraries)
JSTL Core Library
JSP Custom Tags
►JSP Java Tag Interface
IterationTag Interface Test Class - TraceTag.java
IterationTag Interface Test JSP - TraceTagTest.jspx
Servlet Class Converted from JSP - TraceTagTest_jsp.java
TagSupport Class - Dummy Implementation of IterationTag
Custom Tag Attributes
Multiple Tags Working Together
File Upload Test Application
PDF Printing Version