-
- All Superinterfaces:
- JspTag
- All Known Implementing Classes:
- SimpleTagSupport
public interface SimpleTag extends JspTag
Interface for defining Simple Tag Handlers.Simple Tag Handlers differ from Classic Tag Handlers in that instead of supporting
doStartTag()
anddoEndTag()
, theSimpleTag
interface 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 aJspFragment
object 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.
- 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()
andsetParent()
methods are called by the container. ThesetParent()
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 aJspFragment
. 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.
- Since:
- JSP 2.0
- See Also:
SimpleTagSupport
-
-
Method Summary
All Methods Instance Methods Abstract Methods 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 theJspContext
for this invocation.void
setParent(JspTag parent)
Sets the parent of this tag, for collaboration purposes.
-
-
-
Method Detail
-
doTag
void doTag() throws JspException, IOException
Called by the container to invoke this tag. The implementation of this method is provided by the tag library developer, and handles all tag processing, body iteration, etc.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().
- Throws:
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.
-
setParent
void setParent(JspTag parent)
Sets the parent of this tag, for collaboration purposes.The container invokes this method only if this tag invocation is nested within another tag invocation.
- Parameters:
parent
- the tag that encloses this tag
-
getParent
JspTag getParent()
Returns the parent of this tag, for collaboration purposes.- Returns:
- the parent of this tag
-
setJspContext
void setJspContext(JspContext pc)
Called by the container to provide this tag handler with theJspContext
for this invocation. An implementation should save this value.- Parameters:
pc
- the page context for this invocation- See Also:
Tag.setPageContext(javax.servlet.jsp.PageContext)
-
setJspBody
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.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.- Parameters:
jspBody
- The fragment encapsulating the body of this tag.
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 18/08/2025 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-javaee-rf-javax/servlet/jsp/tagext/SimpleTag.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur van deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.