javax.servlet.jsp.tagext

Interface TryCatchFinally

  • All Known Implementing Classes:
    LoopTagSupport

    public interface TryCatchFinally
    The auxiliary interface of a Tag, IterationTag or BodyTag tag handler that wants additional hooks for managing resources.

    This interface provides two new methods: doCatch(Throwable) and doFinally(). The prototypical invocation is as follows:

     h = get a Tag();  // get a tag handler, perhaps from pool
    
     h.setPageContext(pc);  // initialize as desired
     h.setParent(null);
     h.setFoo("foo");
     
     // tag invocation protocol; see Tag.java
     try {
       doStartTag()...
       ....
       doEndTag()...
     } catch (Throwable t) {
       // react to exceptional condition
       h.doCatch(t);
     } finally {
       // restore data invariants and release per-invocation resources
       h.doFinally();
     }
     
     ... other invocations perhaps with some new setters
     ...
     h.release();  // release long-term resources
     
    • Method Detail

      • doCatch

        void doCatch(Throwable t)
              throws Throwable
        Invoked if a Throwable occurs while evaluating the BODY inside a tag or in any of the following methods: Tag.doStartTag(), Tag.doEndTag(), IterationTag.doAfterBody() and BodyTag.doInitBody().

        This method is not invoked if the Throwable occurs during one of the setter methods.

        This method may throw an exception (the same or a new one) that will be propagated further up the nest chain. If an exception is thrown, doFinally() will be invoked.

        This method is intended to be used to respond to an exceptional condition.

        Parameters:
        t - The throwable exception navigating through this tag.
        Throws:
        Throwable - if the exception is to be rethrown further up the nest chain.
      • doFinally

        void doFinally()
        Invoked in all cases after doEndTag() for any class implementing Tag, IterationTag or BodyTag. This method is invoked even if an exception has occurred in the BODY of the tag, or in any of the following methods: Tag.doStartTag(), Tag.doEndTag(), IterationTag.doAfterBody() and BodyTag.doInitBody().

        This method is not invoked if the Throwable occurs during one of the setter methods.

        This method should not throw an Exception.

        This method is intended to maintain per-invocation data integrity and resource management actions.

Document created the 11/06/2005, last modified the 18/08/2025
Source of the printed document:https://www.gaudry.be/en/java-api-javaee-rf-javax/servlet/jsp/tagext/TryCatchFinally.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.

References

  1. View the html document Language of the document:fr Manuel PHP : https://docs.oracle.com, TryCatchFinally (Java(TM) EE 7 Specification APIs)

These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author of this site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.