fedora core 3
apache 2
perl/CGI
I have a CGI application that accepts inputs from a user, passes those inputs to a piece of java which takes 30-45 seconds to build their results, and then redirects the browser the output which has been built by the java run. Because the java stuff takes so long, I'd like to give my users some indication that their request has been submitted and it will take a few seconds to deliver their results. In the following, for simplicity sake, I have substituted a simple piece of Perl(spoon.pl) to emulate the long java process.
I have been able to make a this work in mozilla and firefox browsers using a fork, but, I can't get it to work for IE.
Driver.cgi
Since mozilla and family render the page as it is delivered (to some degree), the above code shows 'Working...' with more dots slowly appearing until the child process completes. This is just what I want, but, IE will not render any of the page until it has the complete page. So, IE shows a blank page until, the child (java) finishes and then immediately does the redirect.
spoon.pl - this is a spoon since the other is a 'fork' ;-)
Ideas?
'hope this helps
If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
apache 2
perl/CGI
I have a CGI application that accepts inputs from a user, passes those inputs to a piece of java which takes 30-45 seconds to build their results, and then redirects the browser the output which has been built by the java run. Because the java stuff takes so long, I'd like to give my users some indication that their request has been submitted and it will take a few seconds to deliver their results. In the following, for simplicity sake, I have substituted a simple piece of Perl(spoon.pl) to emulate the long java process.
I have been able to make a this work in mozilla and firefox browsers using a fork, but, I can't get it to work for IE.
Driver.cgi
Code:
#!/usr/bin/perl
use strict;
use CGI;# qw('fatalsToBrowser', 'warngingsToBrowser');
my $http = new CGI;
my $pid;
my $time = localtime;
$| = 1;
if ($pid = fork) { # this is the parent
print $http->header(-title=>"Process Monitor"),
qq(<body bgcolor="#0000FF"
onload="location.href='[URL unfurl="true"]http://localhost/'">[/URL]
<font color="#FFFFFF"><p>Working...);
}
else { # this is the child
close (STDOUT);
# java writes stuff to a db - but I'm playing
# with a simple text file for now
system ("/usr/bin/perl", "/path/to/spoon.pl");
exit(0);
}
# This is parent process again.
# Check to see if the text file is there.
while (!(-e '/var/[URL unfurl="true"]www/cache/junk.txt'))[/URL] {
sleep(1);
print ".";
}
print qq(</p><p>$time Done! </p></font>),
$http->end_html;
Since mozilla and family render the page as it is delivered (to some degree), the above code shows 'Working...' with more dots slowly appearing until the child process completes. This is just what I want, but, IE will not render any of the page until it has the complete page. So, IE shows a blank page until, the child (java) finishes and then immediately does the redirect.
spoon.pl - this is a spoon since the other is a 'fork' ;-)
Code:
#!/usr/bin/perl
use strict;
# emulate a long java run before writing the text file.sleep(5);
my $time = localtime();
open(OPF,">/var/[URL unfurl="true"]www/cache/junk.txt")[/URL]
or die "Failed to open OPF: $!\n";
print OPF "spoon.pl ran at $time\n";
close OPF;
Ideas?
'hope this helps
If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.