public interface SimpleTag extends JspTag
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.
setJspContext()
and setParent()
methods are called by the container. The setParent()
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 a
JspFragment
. 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.SimpleTagSupport
Modifier and Type | Method and Description |
---|---|
void |
doTag()
Called by the container to invoke this tag.
|
JspTag |
getParent()
Returns the parent of this tag, for collaboration purposes.
|
void |
setJspBody(JspFragment jspBody)
Provides the body of this tag as a JspFragment object, able to be
invoked zero or more times by the tag handler.
|
void |
setJspContext(JspContext pc)
Called by the container to provide this tag handler with
the
JspContext for this invocation. |
void |
setParent(JspTag parent)
Sets the parent of this tag, for collaboration purposes.
|
void doTag() throws JspException, IOException
The JSP container will resynchronize any AT_BEGIN and AT_END variables (defined by the associated tag file, TagExtraInfo, or TLD) after the invocation of doTag().
JspException
- If an error occurred
while processing this tag.SkipPageException
- If the page that
(either directly or indirectly) invoked this tag is to
cease evaluation. A Simple Tag Handler generated from a
tag file must throw this exception if an invoked Classic
Tag Handler returned SKIP_PAGE or if an invoked Simple
Tag Handler threw SkipPageException or if an invoked Jsp Fragment
threw a SkipPageException.IOException
- If there was an error writing to the
output stream.void setParent(JspTag parent)
The container invokes this method only if this tag invocation is nested within another tag invocation.
parent
- the tag that encloses this tagJspTag getParent()
void setJspContext(JspContext pc)
JspContext
for this invocation.
An implementation should save this value.pc
- the page context for this invocationTag.setPageContext(javax.servlet.jsp.PageContext)
void setJspBody(JspFragment jspBody)
This method is invoked by the JSP page implementation
object prior to doTag()
. If the action element is
empty in the page, this method is not called at all.
jspBody
- The fragment encapsulating the body of this tag.Copyright © 1996-2013, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.