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).

In reply to Re: Applet to Perl(cgi) by Errto
in thread Applet to Perl(cgi) by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.