Andrew Cooke wrote:

> Hi,
>
> I would like to use a Custom Tag to open resources in the start tag and free
> them in the closing tag.  But if there is an exception in the enclosed body,
> it seems that I will leak the resource (as the closing tag will not be
> called).
>
> For example, if I open a database connection in doStartTag and fail to close
> it in doEndTag (because an exception was thrown) then I will have an open DB
> connection that is not returned to the pool.
>
> What is the best way to avoid this problem?


This is exactly what the TryCatchFinally interface is for, added
in JSP 1.2. For a JSP 1.1 container, I'm afraid there is no solution.

Hans
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com
JavaServer Pages        http://TheJSPBook.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to