Simple Tag Handlers differ from Classic Tag Handlers in that instead
of supporting doStartTag() and doEndTag(),
the SimpleTag interface provides a simple
doTag() method, which is called once and only once for any
given tag invocation. All tag logic, iteration, body evaluations, etc.
are to be performed in this single method. Thus, simple tag handlers
have the equivalent power of BodyTag, but with a much
simpler lifecycle and interface.
To support body content, the setJspBody()
method is provided. The container invokes the setJspBody()
method with a JspFragment object encapsulating the body of
the tag. The tag handler implementation can call
invoke() on that fragment to evaluate the body as
many times as it needs.
A SimpleTag handler must have a public no-args constructor. Most
SimpleTag handlers should extend SimpleTagSupport.
Lifecycle
The following is a non-normative, brief overview of the
SimpleTag lifecycle. Refer to the JSP Specification for details.
A new tag handler instance is created each time by the container
by calling the provided zero-args constructor. Unlike classic
tag handlers, simple tag handlers are never cached and reused by
the JSP container.
The setJspContext() and setParent()
methods are called by the container. The setParent()
method is only called if the element is nested within another tag
invocation.
The setters for each attribute defined for this tag are called
by the container.
If a body exists, the setJspBody() method is called
by the container to set the body of this tag, as a
JspFragment. If the action element is empty in
the page, this method is not called at all.
The doTag() method is called by the container. All
tag logic, iteration, body evaluations, etc. occur in this
method.
The doTag() method returns and all variables are
synchronized.
Simple Tag Handlers differ from Classic Tag Handlers in that instead of supporting
doStartTag()anddoEndTag(), theSimpleTaginterface provides a simpledoTag()method, which is called once and only once for any given tag invocation. All tag logic, iteration, body evaluations, etc. are to be performed in this single method. Thus, simple tag handlers have the equivalent power ofBodyTag, but with a much simpler lifecycle and interface.To support body content, the
setJspBody()method is provided. The container invokes thesetJspBody()method with aJspFragmentobject encapsulating the body of the tag. The tag handler implementation can callinvoke()on that fragment to evaluate the body as many times as it needs.A SimpleTag handler must have a public no-args constructor. Most SimpleTag handlers should extend SimpleTagSupport.
Lifecycle
The following is a non-normative, brief overview of the SimpleTag lifecycle. Refer to the JSP Specification for details.
setJspContext()andsetParent()methods are called by the container. ThesetParent()method is only called if the element is nested within another tag invocation.setJspBody()method is called by the container to set the body of this tag, as aJspFragment. If the action element is empty in the page, this method is not called at all.doTag()method is called by the container. All tag logic, iteration, body evaluations, etc. occur in this method.doTag()method returns and all variables are synchronized.