shebang has asked for the wisdom of the Perl Monks concerning the following question:

How can I grab data from a java applet using perl? I have seen it done in VB. Actually I need to grab data from a Java Stock Ticker. How can I do this in perl? Please suggest:)

Replies are listed 'Best First'.
Re: Grabbing data from a java applet
by stephen (Priest) on May 05, 2001 at 20:21 UTC
    If you're talking about getting data from a client-side Java applet to a server-side Perl script, you need to have the applet make a network connection to pass the data. One way would be to write a CGI script in Perl to accept the data, then have the applet submit the data as a CGI request. (See CGI for information on how to write a CGI script, and check out the and classes for more information on how to submit an HTTP request.)

    The applet may or may not be able to make such a connection, depending on the security options that the browser's user has chosen.

    If you just need information about stock quotes, I suggest you check out the Finance::Quote module, which you can use to fetch quotes from a variety of different sites. I suspect that this method may be your best option. (I haven't used it myself, but it appears to be a well-developed module.) If you use it successfully, you may want to submit a review of it to our Module Reviews section.


Re: Grabbing data from a java applet
by r.joseph (Hermit) on May 06, 2001 at 00:18 UTC
    I agree with what both stephen and dws said, and I have had some really good luck with Finance::Quote on a variety of sites. I would think that using a full Java applet would be somewhat overkill - I assume that you need to get the stock quotes from the applet to display on a dynamically generated page? If so, then the overhead needed to load the Java applet would be much greater than the overhead to just execute a CGI script.

    And as dws said, unless you are writing the Java applet yourself (in which case I imagine that you would already know how to pass data to the perl script), I doubt that you want to reverse engineer the whole applet :). Just my $0.02!

    r. j o s e p h
    "Violence is a last resort of the incompetent" - Salvor Hardin, Foundation by Issac Asimov
Re: Grabbing data from a java applet
by dws (Chancellor) on May 05, 2001 at 22:50 UTC
    I need to grab data from a Java Stock Ticker. How can I do this in perl?

    Unless the applet exposes an API that's JavaScript callable, your best bet may be to reverse-engineer the applet's data stream.