Re: Trapping browser events
On Fri, 12 Apr 2002, Jacob Elder wrote: last if $r-connection-aborted; There's a more full discussion of this in the mod_perl developer's cookbook in section 4.8. They postulate a module for checking a little more carefully, source of which is here: http://www.modperlcookbook.org/code/ch04/Cookbook/CheckConnection.pm Later. Mark. -- s'' Mark Fowler London.pm Bath.pm http://www.twoshortplanks.com/ [EMAIL PROTECTED] ';use Term'Cap;$t=Tgetent Term'Cap{};print$t-Tputs(cl);for$w(split/ +/ ){for(0..30){$|=print$t-Tgoto(cm,$_,$y). $w;select$k,$k,$k,.03}$y+=2}
Re: Trapping browser events
Mark Fowler wrote: On Fri, 12 Apr 2002, Jacob Elder wrote: last if $r-connection-aborted; There's a more full discussion of this in the mod_perl developer's cookbook in section 4.8. They postulate a module for checking a little more carefully, source of which is here: http://www.modperlcookbook.org/code/ch04/Cookbook/CheckConnection.pm that particular discussion happens to be available online (along with the rest of chapter 4) if you haven't made it to the bookstore yet :) http://www.webreference.com/programming/perl/cookbook/chap4/5.html --Geoff
Trapping browser events
I am using Embperl on an intranet system to perform complex database searches and display the results. My problem is that, depending on the parameters given by the user, some searches can take some time - returning thousands of rows, and there is a danger that the user will hit the stop button, execute the Back command or even close the browser session altogether. If this happens at the wrong time, an oracle connection could have been made, but no SQL sent to it, leaving an Oracle process hanging there. I need to be able to trap these browser events, and I can then call a cleanup routine to close any database connections. I can use the Javascript onUnload event, I can't figure how to commmuncate with the Perl process. Any ideas would be welcome. Martin Harriss Cambridge UK
Re: Trapping browser events
Jacob Elder wrote: On Tue, Apr 09, 2002 at 11:13:09AM +0100, Martin Harriss wrote: I am using Embperl on an intranet system to perform complex database searches and display the results. My problem is that, depending on the parameters given by the user, some searches can take some time - returning thousands of rows, and there is a danger that the user will hit the stop button, execute the Back command or even close the browser session altogether. If this happens at the wrong time, an oracle connection could have been made, but no SQL sent to it, leaving an Oracle process hanging there. I need to be able to trap these browser events, and I can then call a cleanup routine to close any database connections. I can use the Javascript onUnload event, I can't figure how to commmuncate with the Perl process. I don't remember where I saw this, but I think it might be what you're looking for. while ($dbh-fetch) { # format, print, etc. last if $r-connection-aborted; } $dbh-disconnect; Remember that if you're using Apache::DBI, your database connection will be persistant anyway, so that's not a total waste :) The above code's still a good idea (although the $dbh-disconnect will be silently ignored under Apache::DBI) as it will still free the process (or thread soon :)) which is dealing with the current response, which would otherwise still have lots of work to do for a client who's no longer interested. Issac