You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jeff Trent <jt...@structsoft.com> on 2001/06/04 23:51:20 UTC
Managing resource life cycle during request
I was wondering how other people deal with physical resource objects (eg. db result sets, etc.) during a request. Before struts, I use to allocate the resource, call request.setAttribute() with the resource object, call request dispatcher (to do jsp presentation), then clean up the resource back in the servlet upon return. In struts, this has all been abstracted out. Is there an alternative way to manage request-scoped resources like this under struts?
thanks,
jeff
Re: Managing resource life cycle during request
Posted by Ted Husted <hu...@apache.org>.
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...
Re: Managing resource life cycle during request
Posted by Jeff Trent <jt...@structsoft.com>.
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...
----- Original Message -----
From: "Jeff Trent" <jt...@structsoft.com>
To: <st...@jakarta.apache.org>
Sent: Monday, June 04, 2001 10:54 PM
Subject: Re: Managing resource life cycle during request
> That's sounds okay for simple forms, but I'd rather not serialize objects
> from a multi-row recordset to a collection every time. Too much overhead!
> Let me put the question another way, in Struts, what method on the form or
> action class gets called following the rendering of the input page? I'll
> check source code now for this answer...
>
> - jeff
>
> ----- Original Message -----
> From: "Ted Husted" <hu...@apache.org>
> To: <st...@jakarta.apache.org>
> Sent: Monday, June 04, 2001 9:25 PM
> Subject: Re: Managing resource life cycle during request
>
>
> > The types of objects I use for presentation should be disposed and
> > garbage collected. Here we would be talking about standard collections
> > of mainly Strings and maybe a few primitive types. Anything kinky would
> > be handled in the action. The view gets everything handed to it on a
> > silver platter.
> >
> > Jeff Trent wrote:
> > >
> > > Ted,
> > >
> > > Just because the objects are held in the bean doesn't necessary mean
> they
> > > will automatically be cleaned-up. Am I missing something here? I
also
> > > agree, I don't want to be writing queries within the JSP.
> > >
> > > Thanks,
> > > - jeff
> >
>
>
Re: Managing resource life cycle during request
Posted by Ted Husted <hu...@apache.org>.
Following the rendering? By Struts? None.
It's a straight JSP (or other view technology, like a Velocity
template).
Generally, things go into the request, and are disposed when the request
is disposed.
There's an enhancement to the iterate tag in the works that uses a
RowSet directly.
<
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg07910.html
>
Jeff Trent wrote:
>
> That's sounds okay for simple forms, but I'd rather not serialize objects
> from a multi-row recordset to a collection every time. Too much overhead!
> Let me put the question another way, in Struts, what method on the form or
> action class gets called following the rendering of the input page? I'll
> check source code now for this answer...
>
> - jeff
Re: Managing resource life cycle during request
Posted by Jeff Trent <jt...@structsoft.com>.
That's sounds okay for simple forms, but I'd rather not serialize objects
from a multi-row recordset to a collection every time. Too much overhead!
Let me put the question another way, in Struts, what method on the form or
action class gets called following the rendering of the input page? I'll
check source code now for this answer...
- jeff
----- Original Message -----
From: "Ted Husted" <hu...@apache.org>
To: <st...@jakarta.apache.org>
Sent: Monday, June 04, 2001 9:25 PM
Subject: Re: Managing resource life cycle during request
> The types of objects I use for presentation should be disposed and
> garbage collected. Here we would be talking about standard collections
> of mainly Strings and maybe a few primitive types. Anything kinky would
> be handled in the action. The view gets everything handed to it on a
> silver platter.
>
> Jeff Trent wrote:
> >
> > Ted,
> >
> > Just because the objects are held in the bean doesn't necessary mean
they
> > will automatically be cleaned-up. Am I missing something here? I also
> > agree, I don't want to be writing queries within the JSP.
> >
> > Thanks,
> > - jeff
>
Re: Managing resource life cycle during request
Posted by Ted Husted <hu...@apache.org>.
The types of objects I use for presentation should be disposed and
garbage collected. Here we would be talking about standard collections
of mainly Strings and maybe a few primitive types. Anything kinky would
be handled in the action. The view gets everything handed to it on a
silver platter.
Jeff Trent wrote:
>
> Ted,
>
> Just because the objects are held in the bean doesn't necessary mean they
> will automatically be cleaned-up. Am I missing something here? I also
> agree, I don't want to be writing queries within the JSP.
>
> Thanks,
> - jeff
Re: Managing resource life cycle during request
Posted by Jeff Trent <jt...@structsoft.com>.
Ted,
Just because the objects are held in the bean doesn't necessary mean they
will automatically be cleaned-up. Am I missing something here? I also
agree, I don't want to be writing queries within the JSP.
Thanks,
- jeff
----- Original Message -----
From: "Ted Husted" <hu...@apache.org>
To: <st...@jakarta.apache.org>
Sent: Monday, June 04, 2001 6:13 PM
Subject: Re: Managing resource life cycle during request
> In general, you should put everything you need for the presentation into
> a JavaBean, release any other resources, and return just the bean in the
> request. This way you also do things like immediately return the
> connection to the pool (before anything bad happens).
>
> As and for an alternative, the Jakarta JDBC tags work great with Struts
> too, if you like doing things on the page.
>
> Personally, I use mostly RowSets, which can be disconnected from the
> data source as soon as the command completes. The Struts tags don't
> support RowSets directly (yet) so I end up pounding the RowSet into a
> value object bean and/or an ArrayList for iterate (though a fix for that
> is in the works too).
>
> For more, see Part 2 of Strut by Strut under "Coming Soon" at <
> http://www.husted.com/about/struts/ >
>
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Custom Software ~ Technical Services.
> -- Tel 716 737-3463.
> -- http://www.husted.com/about/struts/
>
>
> > Jeff Trent wrote:
> >
> > I was wondering how other people deal with physical resource objects
> > (eg. db result sets, etc.) during a request. Before struts, I use to
> > allocate the resource, call request.setAttribute() with the resource
> > object, call request dispatcher (to do jsp presentation), then clean
> > up the resource back in the servlet upon return. In struts, this has
> > all been abstracted out. Is there an alternative way to manage
> > request-scoped resources like this under struts?
> >
> > thanks,
> > jeff
> >
>
Re: Managing resource life cycle during request
Posted by Ted Husted <hu...@apache.org>.
In general, you should put everything you need for the presentation into
a JavaBean, release any other resources, and return just the bean in the
request. This way you also do things like immediately return the
connection to the pool (before anything bad happens).
As and for an alternative, the Jakarta JDBC tags work great with Struts
too, if you like doing things on the page.
Personally, I use mostly RowSets, which can be disconnected from the
data source as soon as the command completes. The Struts tags don't
support RowSets directly (yet) so I end up pounding the RowSet into a
value object bean and/or an ArrayList for iterate (though a fix for that
is in the works too).
For more, see Part 2 of Strut by Strut under "Coming Soon" at <
http://www.husted.com/about/struts/ >
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 737-3463.
-- http://www.husted.com/about/struts/
> Jeff Trent wrote:
>
> I was wondering how other people deal with physical resource objects
> (eg. db result sets, etc.) during a request. Before struts, I use to
> allocate the resource, call request.setAttribute() with the resource
> object, call request dispatcher (to do jsp presentation), then clean
> up the resource back in the servlet upon return. In struts, this has
> all been abstracted out. Is there an alternative way to manage
> request-scoped resources like this under struts?
>
> thanks,
> jeff
>