>I'm not suggesting that coding this way is wrong. I would suggest that this
>isn't optimal model/view separation, which is one of the main motives for
>using Struts, right?
What really is true model/view separation. In the 15 years or so that I've
been coding, I find this to be more of an academic pursuit. The alternative
is to make it a collection which, imho, is not cleaner since it has its own
downsides.
My $0.02,
- jeff
----- Original Message -----
From: "Cook, Levi" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 05, 2001 4:20 PM
Subject: RE: Managing resource life cycle during request
> Just a few notes:
>
> 1. Struts doesn't dissallow the operations you outline below. If you are
> using Struts, and you really need to do this, you can make the same calls
> from your Action implementation.
>
> public class SomeAction extends Action {
> public ActionForward perform(ActionMapping mapping, ActionForm form,
> HttpServletRequest request, HttpServletResponse response)
> throws IOException, ServletException {
> ServletContext context = servlet.getServletContext();
> RequestDispatcher dispatcher =
context.getRequestDispatcher(<jspFile>);
>
> rs <- <dbquery>
> request.setAttribute("rs", rs);
> dispatcher.include(request, response);
> rs.close();
>
> // ActionServlet doesn't do any more response processing..
> return null;
> }
> }
>
> I'm not suggesting that coding this way is wrong. I would suggest that
this
> isn't optimal model/view separation, which is one of the main motives for
> using Struts, right?
>
> 2. My use of the term "acquiring" may have been wrong, or at least
> ambiguous. More accurately, I would suggest that view components should
not
> have knowledge of, or responsibility for non-memory, finite resources.
>
> 3. You must rely on Garbage collection in Java, you may not like its
> behaviors, but its all you get. Also, I would never suggest that you rely
on
> garbage collection to free, non-memory resources, like db-handles.
>
> -- Levi
>
>
>
> -----Original Message-----
> From: Jeff Trent [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 05, 2001 2:05 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Managing resource life cycle during request
>
>
> Levi,
>
> The view/JSP does not acquire the resource. Here is a sample of how the
> code use to work pre-struts:
> Servlet.doGet()
> {
> ...
> rs <- <dbquery>
> request.setAttribute("rs", rs)
>
> requestDispatcher.include(<jspFile>)
>
> rs.close();
> }
>
> In JSP:
> ...
> rs = request.getAttribute("rs")
> while (rs.next())
> {
> ...
> }
>
> - - -
>
> The problem is that there is no appropriate counterpart in the world of
> struts. Sure, I can copy the row data to a collection and then walk the
> collection. But for various reasons, this may be inappropriate
(especially
> for large result sets represented by a cursor).
>
> Finally, you should not depend on garbage collection. The garbage
collector
> is not always called and its certainly not called as often as you would
want
> it to when you need to free scarce resources like db handles.
>
> - jeff
>
>
> ----- Original Message -----
> From: "Cook, Levi" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, June 05, 2001 1:40 PM
> Subject: RE: Managing resource life cycle during request
>
>
> > Can you elaborate on your resource cleanup requirements?
> >
> > My view on designing a responsible object is that I must make sure it
> > eventually releases any, non-memory, finite resources it uses. This
design
> > strategy, coupled with garbage collection ensures my system doesn't run
> out
> > of those resources (eg. file handles, sockets, etc.).
> >
> > Given that ActionForms and JSPs should play the "view" role in Struts, I
> > would question a design that has them acquiring non-memory resources.
But,
> > alas, I don't know your system or situation..
> >
> > Regards,
> > Levi Cook
> >
> >
> > -----Original Message-----
> > From: Ted Husted [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, June 04, 2001 10:31 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: Managing resource life cycle during request
> >
> >
> > I doubt that overriding ActionServlet.process() would work. The
> > controller sends back the response, and it's done. It's then up to HTTP
> > to deliver the view, usually a JSP.
> >
> > Any clean-up routine would have to be the responsibility of the view,
> > which puts you into the scriplet zone.
> >
> > Jeff Trent wrote:
> > >
> > > Well, it looks to me that short of overriding ActionServlet.process(),
> > there
> > > is no way one can clean-up resources after the page has been
rendered...
> >