and on the client, you would have a method to retrieve the data (assuming your users have the Java Plug-in with JRE1.4 or above):print "Content-type: text/plain\n\n"; my $param = 1; foreach my $fields (@$data) { my $name = $param++; my $value = join('|', @$fields); print "$value\n"; }
This takes advantage of the fact that when you use a URLConnection in an applet, it automatically picks up the appropriate proxy settings, user-agent, cookies etc from the browser. Also remember that the CGI will have to live on the same server as the applet unless the applet is signed (for security reasons).import java.net.URL; import java.net.HttpURLConnection; import java.io.BufferedReader; import java.io.InputStreamReader; ... URL url = new URL(getCodeBase(), "/cgi-bin/getmydata.pl"); // or whate +ver HttpURLConnection con = (HttpURLConnection) con.openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader(con.getIn +putStream())); String s; int count = 0; while ((s = in.readLine()) != null) { String[] fields = s.split("\\|"); count++; // do something with count and fields } in.close(); con.disconect();
In reply to Re: Applet to Perl(cgi)
by Errto
in thread Applet to Perl(cgi)
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |