In the process of executing a page with a multitude of tag extensions, one
tends to create objects which need to be release()d, close()d, dispose()d,
or otherwise free some resources back to the system.  [Aside: wouldn't it be
nice if we agreed on the name of this method across all java apis!]

It isn't clear where these method calls belong.

One could define special tags which call the appropriate methods and scatter
these calls throughout the page -- one may want to do this anyway, depending on
the complexity of the page.  One may want to code this as a scriptlet, instead.
But managing this becomes complex with tag extensions which arbitrarily forward
control to other pages, and in general, it would be nice to have a centralized
resouce releaser.

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.

      [It may be useful to have releasePageContext(JspFactory, pageContext) on
       the servlet instance and allow users to override it.  This call (the one
       currently on factory) needs to be made before 'return' anyway, and if moved
       to the Servlet, would allow one place for jsp-page-specific cleanup to
       happen.]

   c) I can't wrap the page in either a scriplet ala:
      <% try { %>
      [everything else]
      <% } finally { freeMyResources(request); } %>

      or in tags, because forwarding implies a 'return' from the _jspService
      method.  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.

So, okay, I'm stumped.  It seems like a _jspFreeResources(HttpServletRequest req),
is something that ought to be provided in the spec, but if it isn't, how should I
do this?

I'd rather not implement a vendor-specific HttpServletRequest that knew how to
free certain types of resources from its attribute hash, but that seems to be
what I'm reduced to at the moment :(

-Dave

===========================================================================
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