It seems few have any need for or experience with this problem.
I will therefore offer my solution, if you can call it that.
Until I find a better solution, here is what seems servicable. On the page that could navigate to the CGI script, have a note telling the user that to see the result of clicking on the link, he needs to have popup windows enabled. Then, the target for the hyperlink is set to be a new window. This seems to work fine on both MS IE and FireFox. The output from the CGI script appears in a new window, or in a new tab if the browser is configured that way (on my system, firefox opens these pages in new tab while MS IE opens them in a new window). The original page remains visible, and navigation from that page to a new page maintains state.
Does anyone have a better option?
Ted
Ted Byers wrote:
I'm using an older Apache httpd server (version 2.0.? - haven't upgraded yet), as well as Tomcat 6.0.16, with NetBeans 6.1. And I am using perl 5.8. Knowledge of perl would be useful in understanding the CGI programming I show below.
This is a Visual Web app, and the only reason I am exploring CGI programming in perl here is that I have yet to find a way to have my button event handlers invoke an external executable program! I know I can do what I need to do here using CGI on Apache's httpd server (assuming I can figure out how to maintain session moving from one server to another and back again).
I figured out how to get CGI working on Tomcat 6 (what wasn't in the documentation at the time I did this was that the context had to be edited to have privileged set to true - that plus the instructions provided gets CGI working after a fashion on Tomcat 6). One thing that is baffling is that none of this works from within NetBeans. I have no idea why. But I am not worried about that.
Something else I have found that is even more baffling is this. A practice I routinely use on Apache's httpd server, which works fine, does not work when I try it
Here is an illustrative code snippet:
my $output = `C:\\ApacheAndPerl\\Apache2\\perl\\printenv_segment.pl`;
print "$output<br><br><br><br>";
$output = `dir`;
print '<PRE>';
print "$output<br>";
print '</PRE>';
print '</BODY></HTML>';
And here is printenv_segment.pl:
#!C:/Perl/bin/perl
print '<H3>Environment variables</H3><UL>';
foreach my $var (sort keys %ENV) {
my $val = $ENV{$var};
$val =~ s|\n|\\n|g;
$val =~ s|"|\\"|g;
print qq{<LI>${var} = "${val}"</LI>\n};
}
print '</UL>';
Obviously ALL I did is extract enough code from the printenv perl script that was distributed with the windows version of httpd that had been bundled with a distribution of perl. Any code that prints something to standard out would do (though to be legible, you'd have to wrap it in <PRE></PRE> as I did for Windows' dir command above.
The point is that this works PERFECTLY using CGI on Apache's httpd server and yet nothing written to standard out by the child script is captured and added to the page when the same code is executed within Tomcat 6's CGI. WHY? Is CGI on Tomcat 6 not able to handle child CGI scripts? If not, I can work with CGI on Apache's httpd server, but then I have to figure out how to maintain session state when moving from a JSP page on Tomcat to a page (created by a CGI perl script) on Apache's httpd server, and back. My application has a login, and that login info has to be maintained through this route.
Ideally, I'd want to invoke the cgi script from within the event handler for a Woodstock button (is it even possible to forward a request to a different server from within such an event handler?), but I can live with a Woodstock hyperlink if I must.
Thanks
Ted