- java.lang.Object
-
- javax.servlet.jsp.tagext.JspFragment
-
public abstract class JspFragment extends Object
Encapsulates a portion of JSP code in an object that can be invoked as many times as needed. JSP Fragments are defined using JSP syntax as the body of a tag for an invocation to a SimpleTag handler, or as the body of a <jsp:attribute> standard action specifying the value of an attribute that is declared as a fragment, or to be of type JspFragment in the TLD.The definition of the JSP fragment must only contain template text and JSP action elements. In other words, it must not contain scriptlets or scriptlet expressions. At translation time, the container generates an implementation of the JspFragment abstract class capable of executing the defined fragment.
A tag handler can invoke the fragment zero or more times, or pass it along to other tags, before returning. To communicate values to/from a JSP fragment, tag handlers store/retrieve values in the JspContext associated with the fragment.
Note that tag library developers and page authors should not generate JspFragment implementations manually.
Implementation Note: It is not necessary to generate a separate class for each fragment. One possible implementation is to generate a single helper class for each page that implements JspFragment. Upon construction, a discriminator can be passed to select which fragment that instance will execute.
- Since:
- JSP 2.0
-
-
Constructor Summary
Constructors Constructor and Description JspFragment()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description abstract JspContext
getJspContext()
Returns the JspContext that is bound to this JspFragment.abstract void
invoke(Writer out)
Executes the fragment and directs all output to the given Writer, or the JspWriter returned by the getOut() method of the JspContext associated with the fragment if out is null.
-
-
-
Method Detail
-
invoke
public abstract void invoke(Writer out) throws JspException, IOException
Executes the fragment and directs all output to the given Writer, or the JspWriter returned by the getOut() method of the JspContext associated with the fragment if out is null.- Parameters:
out
- The Writer to output the fragment to, or null if output should be sent to JspContext.getOut().- Throws:
JspException
- Thrown if an error occured while invoking this fragment.SkipPageException
- Thrown if the page that (either directly or indirectly) invoked the tag handler that invoked this fragment is to cease evaluation. The container must throw this exception if a Classic Tag Handler returned Tag.SKIP_PAGE or if a Simple Tag Handler threw SkipPageException.IOException
- If there was an error writing to the stream.
-
getJspContext
public abstract JspContext getJspContext()
Returns the JspContext that is bound to this JspFragment.- Returns:
- The JspContext used by this fragment at invocation time.
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
21/08/2025 18:36:03 Cette version de la page est en cache (à la date du 21/08/2025 18:36:03) afin d'accélérer le traitement.Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la version plus récente de la page.
Document créé le 24/12/2007, dernière modification le 18/08/2025
Source du document imprimé : https://www.gaudry.be/java-api-javaee-rf-javax/servlet/jsp/tagext/JspFragment.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.