Cocoon (or any servlet) will only know the user has pressed cancel when it tries to 
write to the Servlet response. By 
that time the database query will (probably) have completed so the damage is already 
done. You can obviously catch 
this exception and close the connection (or probably return it to the connection pool) 
at this point.

You do not want to call the servlet's destry method as this is purely for the servlet 
container to inform the servlet 
that it is going out of service and to tidy itself up (close connections, files, etc). 
A servlet that calls it's own 
destry method will end up (at worst) killing itself, making it unavailable for further 
requests. If you do find a way 
to do this in Cocoon you will probably just end up killing the Cocoon servlet and 
introducing a superb security hole 
that will allow anyone to bring your server down.

If you have very time-consuming or processor expensive queries then this is usually a 
warning that you need to manage 
the data in a different way. This can take the form of caching results, 
offline/scheduled query result generation, 
using materialized views (oracle) to name a few common methods.

I suggest you read up on the servlet specification to clarify the servlet lifecycle 
methods and think about the 
problem in a different way.

Regards,

Paul.
--
Paul Bowler
Aventix Associates Ltd

---------- Original Message -----------
From: Jorg Heymans <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Sent: Thu, 06 Nov 2003 12:47:46 +0100
Subject: Re: servlet destroy() method in Cocoon

> sure, but is a servlet destroyed each time a user presses cancel during 
> the request? That would seem very expensive.
> 
> [EMAIL PROTECTED] wrote:
> 
> > Hi Jorg,
> > 
> > 
> >>-----Message d'origine-----
> >>De: Jorg Heymans [mailto:[EMAIL PROTECTED]
> >>Date: mercredi, 5. novembre 2003 15:33
> >>�: [EMAIL PROTECTED]
> >>Objet: Re: servlet destroy() method in Cocoon
> >>
> >>
> >><extremely-off-the-top-of-my-head>
> >>
> >>Doesn't the servlet specification allow to redirect to a page when 
> >>certain exceptions are thrown? 
> > 
> > 
> > Servlet specification allow to define a destroy() method which is executed after 
> > the servlet has been taken out of 
service.
> > 
> > My problem is where to define this method in Cocoon?
> > 
> > 
> > Regards
> > Sylvain
> > 
> > 
> > 
> > 
> >>If a request is interrupted 
> >>you will get 
> >>something like
> >>java.net.SocketException: Software caused connection abort: 
> >>socket write 
> >>error
> >>         at java.net.SocketOutputStream.socketWrite0(Native Method)
> >>         at 
> >>java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
> >>         at 
> >>java.net.SocketOutputStream.write(SocketOutputStream.java:136)
> >>         at 
> >>org.apache.coyote.http11.InternalOutputBuffer$OutputStreamOutp
> >>utBuffer.doWrite(InternalOutputBuffer.java:668)
> >>.....
> >>
> >>Another thing might be to use try and propagate this error 
> >>(don't ask me 
> >>how) through to  the <map:handle-errors> section of your sitemap.
> >>
> >>I guess trying to catch this exception is key here
> >>
> >></extremely-off-the-top-of-my-head>
> >>
> >>[EMAIL PROTECTED] wrote:
> >>
> >>
> >>>Hello,
> >>>
> >>>Is there a location in Cocoon to define a destroy() method 
> >>
> >>like in Servlet programming?
> >>
> >>>The goal is to close a database connection when the user 
> >>
> >>press the "stop" button on the browser during an execution.
> >>
> >>>Is someone has an experience?
> >>>Thanks
> >>>Sylvain
> >>>
> >>>
> >>
> >>---------------------------------------------------------------------
> >>
> >>>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>>For additional commands, e-mail: [EMAIL PROTECTED]
> >>>
> >>>
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
------- End of Original Message -------


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to