in reply to Applet to Perl(cgi)
Java applets execute on the browsing machine, whereas Perl CGI programs execute on the web server machine. A simple way to send data to a Java applet from a CGI program is to include the data as paramaters to the applet in the HTML. You can use Perl (under CGI) to create this HTML dynamically, as shown in the following code.
use DBI; my $dbh = DBI->connect(...); my $data = $dbh->selectall_arrayref(<<'__EOS__'); SELECT id, name, parent, first_son, next_brother, depth FROM family_tree WHERE ... __EOS__ my $count = @$data; print(<<"__EOS__"); Content-Type: text/html <applet code="family.class" width=610 height=400> <param name="nodes" value="$count"> <!-- 0=unique id (1 based) 1=text 2=parent id 3=first son id (0=none) 4=next brother id (0=none) 5=depth level (0 based) --> __EOS__ my $param = 1; foreach my $fields (@$data) { my $name = $param++; my $value = join('|', @$fields); print("<param name=\"$param\" value=\"$value\">\n"); } print("</applet>\n");
|
|---|