If an exception is thrown during the processing of a custom tag, there's a good chance that the container will catch it, leaving you without a way to gracefully recover resources. For example, an exception might be thrown while the container is evaluating the body of your tag. Realizing that you might like additional control, the JSP specification defines an auxiliary interface that can be used to handle thrown exceptions. The TryCatchFinally interface provides two methods to help you out. doCatch is invoked when the container catches an exception that is thrown during the evaluation of a tag body, or in these methods: doStartTag, doEndTag, doInitBody, and doAfterBody. The method doFinally is always invoked after doEndTag regardless of whether an exception is thrown.