David Navas wrote:

> The problems, as I see it, are as follows:
>    a) I can't override service() to do:
>       public void service(HttpServletRequest req, HttpServletResponse res) throws...
>       {
>           try {
>               _jspService(req, res);
>           }
>           finally {
>               freeMyResources(req);
>           }
>       }
>
>       [Which would have been my first choice.  I really hate final methods -- ick!]
>
>    b) I can't seem to guarantee that releasePageContext() is called -- I'm not
>       sure that this is even in the 1.1 spec anymore, as it isn't mentioned in
>       the .pdf.  The method seems to exist in the JspFactory, rather than the
>       JSPServlet, now, anyway.

There are three places where a JSP page author can allocate limited resources:

1) _jspInit() which is cleaned up by _jspDestroy(), both of which are guaranteed to be
called at the appropriate times in 1.1 spec.
2) <% scriptlets %> It is the responsibility of the JSP author to wrap resource
allocations in try/catch/finally blocks
3) Custom tags.  Tag.release() must be called in a finally block by a JSP 1.1 compliant
implementation of a custom tag.

Implicitly, the JSP engine will allocate resources in the pageContext.  Although not
explictly demanded by the specs, it should be safe to assume that releasePageContext()
will be called in service's finally block for JSP 1.1 compliant implementations (refer
to page 112 and 139 of the JSP 1.1 specs).

Resource allocations and deallocations are mostly handled by a 1.1 compliant JSP engine
in the background - just over-ride the correct methods and rely on the engine to call
them in the right places.

>      Which brings up another interesting point -- are the doEndTag()
>       calls intended to be called even in the case of forward()?  I can
>       imagine some looping tags would hold onto system-type resources as well.

No, it is the responsiblity of the tag author to free up resources before <jsp:forward>
(ie: "a goto and never return") is called.  <jsp:forward> means that the rest of the
page will never be called, including releasePageContext.  Like in C, use goto's with
caution!

--
Michael Hu, Paradox Team, Corel Corporation

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to