Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

push_handler and status page question.

by one4k4 (Hermit)
on Mar 31, 2001 at 00:40 UTC ( #68498=perlquestion: print w/replies, xml ) Need Help??
one4k4 has asked for the wisdom of the Perl Monks concerning the following question:

Morning folks,
I'm currently using mod_perl, and thinking that chaining content headers is the way to go with this, but here is my dillema. (Besides my spelling errors..)

I need to run some stored procedures that take upwards of a minute to generate result sets. Ok, thats grand but I dont want the browser to sit there and twiddle.

I'd like to display an animated gif. Simple. Right? I hope.

I'm looking into stacked handlers in my mod_perl code, but I'm not sure if this is what I need. Is it something in Content-Disposition?

1) Push 'Waiting...' animated gif
2) Process report, Perl waits for result set
3) Perl pushes the report html to the browser as if it opened in a target = _blank window. IE: That same window...
Stumped (or rather -> RTFMing),

_14k4 - (

Replies are listed 'Best First'.
Re: push_handler and status page question.
by sutch (Curate) on Mar 31, 2001 at 01:06 UTC
    One way to handle this is to use an HTML redirect. This has the added benefit of freeing memory in use by mod_perl processes that would otherwise be used for each waiting client connection.

    An outline of how I've planned to handle it (note: I haven't implemented it yet, but plan to soon):

    receive request; if (request has no job_id) { create new job_id; start processing external commands (providing job_id); return an HTTP redirect with a 10 second pause, such as: <meta http-equiv="REFRESH" content="10;URL= +ob_id"> } else { if (external commands have completed) { return results; } else { return the HTTP redirect again; } }
      See, I never really know when the stored procedure will end and return the result set. So I'd really like the 'waiting...' web page to just sit there and refresh with the result set when the SP is done. (As if the connection from $r->send_http_header(...) was kept open... ) This could be anywhere from 3 seconds to 3 minutes. So a content - redirect would probably, most likely, happily, not work. But alas, it is a good idea though.

      _14k4 - (
        I know that one of the major browsers, and maybe just one version of that browser, will redraw the page when new headers are returned. But if you cannot guarantee that your users will use that browser, either IE or NS, then this solution is not viable.

        You may be able to do something with JavaScript, where your image is returned and then hidden when the results are returned.

        I do not understand why you believe the HTTP redirect will not work. If you are concerned about the user having to wait an extra 9 seconds (when using a 10 second delay) then decrease the delay to 5 seconds or even 1 second.

Re: push_handler and status page question.
by one4k4 (Hermit) on Apr 10, 2001 at 19:17 UTC
    I think this is how I'm going to solve this issue. Once I get some time to get back to it again.

    Setup a table in a DB.
    Fork off the process like I was originally going to.
    The result set is stored in the DB. Or, a ref to it. Or something similar.
    The script is sent an ID. Which is the KEY value to the DB the result sets are stored in.
    First thing the script does is check for data in the result_set column, based apon the sent key.

    Yes data, then the result set must be done. So spit_out_html();
    No data, then the result set must not be done. Refresh and try again.
    No Key. When it was never created. Go fork and create the key and refresh to wait for a result set.
    Sound like a plan? We'll see what happens. I'll keep everybody updated on my solution.
    Thank you for all the advice as well. Its been a big help.

    _14k4 - (

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://68498]
Approved by root
[james28909]: in order for there to be a mutation, there has to be a universe with laws setup that even allow a mutation.
[james28909]: everything past the first two things you piked from my posts are irrelevant to me and my beliefs. they are side effects.
[james28909]: two or three. if it has to do with how humans are handling said situations, then that is after they were able to evolve into those problems. agnostic means only believe with evidence. i took that from a tyson video
[james28909]: and it seems that racism suggest that there is indeed a better race, but that is for evolution to decide
[1nickt]: "right now, humans are smarter than in any of those times": define "smart"
[erix]: ah, now you're appraoch downvote-territory ;)

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (12)
As of 2017-12-15 14:57 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (433 votes). Check out past polls.