in reply to Applet to Perl(cgi)

If you need to update the data dynamically, you can have the applet make an HTTP call to the Perl CGI running on the server. In that case, Perl should output the data as plain text instead of HTML. So on the server side your code would look like (adopting ikegami's example):
print "Content-type: text/plain\n\n"; my $param = 1; foreach my $fields (@$data) { my $name = $param++; my $value = join('|', @$fields); print "$value\n"; }
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):
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();
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).

Replies are listed 'Best First'.
Re^2: Applet to Perl(cgi)
by Anonymous Monk on Jun 18, 2005 at 03:35 UTC
    Does this mean, anytime the data is change in database, the applet will automatically change without using refresh/reload?
      It will automatically change if you set your applet to make this http call periodically and then do something with the result. The code I showed only retrieves the data from the server once, so you'll have to write the code to call it once every however often you want.