Another way to do this is with "server push", using CGI::Push. Basically, this involves sending a document of type "multipart/x-mixed-replace", consisting of two or more subdocuments, which can be of any mime type. The key is that the connection is kept open between documents, and each subdocument, as it's made ready by the server and received by the browser, replaces its predecessor. In your case, you'd have two documents:
  1. The "Please wait" page.
  2. The requested data.
Older Microsoft browsers (e.g. IE4) cannot handle server push. However, all modern browsers should have no trouble with it. I've tested it with Netscape 4.76 (Win and Linux), Opera 6 (Win and Linux), and Mozilla (Linux) with no problems. Apache users should note that the script name must start with the prefix "nph-" for this to work, as in "nph-myscript.pl". IIS apparently doesn't have this requirement, although I've not tried it with IIS.

A sample script to illustrate the technique follows:

#!/usr/bin/perl -T use strict; use CGI::Push; my $q = CGI::Push->new; $q->do_push( -next_page => \&Do_wait, -last_page => \&Get_data, -delay => 0 ); sub Do_wait { my ($q, $counter) = @_; return undef if $counter > 1; return '<html>Please wait...</html>' } sub Get_data { sleep 3; # Simulate dbi accesss delay... return "<html>Here's your stuff.</html>" }

In reply to Re: Printing that "waiting" page or call it win32::process::create problem by Dr. Mu
in thread Printing that "waiting" page or call it win32::process::create problem by ikare

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.