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

Okay, I'm bouncing this around on a few different forums, but since I am using Perl CGI - I thought I'd brush it by ya'll too.
Problem: I have a Perl script that is creating an HTML page that includes an applet. When my browser views the page, the applet does not load and gives the following message:
load: class myApplet not found
The Apache error_log reads:
[Tue Apr 3 13:59:59 2001] [error] (8)Exec format error: exec of /usr/ +local/apache/cgi-bin/agency/PieChartApplet.class failed
What I guess is trying to happen is that Apache is trying to 'execute' the applet instead of 'serving' it. I can take a static html file and myApplet into an htdocs directory and view it from a browser no problem, but not when my perl script creates the HTML page.
Question: Has anyone seen this before and is there a Perl workaround that will handle this?
I'm using the latest version of Apache and Perl (and Perl's CGI module). I believe my permissions and ownership for myApplet are correct. It looks like this might be an Apache issue, but I have not been able to find anything on it yet.
Thanks in advance.

Replies are listed 'Best First'.
(crazyinsomniac) Re: cannot load applet using Perl/CGI
by crazyinsomniac (Prior) on Apr 04, 2001 at 00:21 UTC
    It doesn't sound like a cgi problem.

    What you have is a common applet problem, where you, the maker of the htmlfile, do not upload the applet in the same directory as the htmlfile, and then ask for the applet like "appletname".

    My suggestion is to upload the applet to your root directory, and then have your cgi generate an object tag pointing to "/appletname".

    That should work. I don't remember Apache serving files from under the cgi-bin correctly on my poor Apachte conf, and I don't think it will by default(the 2nd part just my opinion, but 1st part true).

    update: /me is just too slow for jeffa

     
    ___crazyinsomniac_______________________________________
    Disclaimer: Don't blame. It came from inside the void

    perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"

(jeffa) Re: cannot load applet using Perl/CGI
by jeffa (Bishop) on Apr 04, 2001 at 00:16 UTC
    I grabbed an old applet that I wrote years ago and wrote a simple CGI script that prints out an applet HTML tag. The applet loaded just fine:
    use strict; use CGI qw(:standard); print header, start_html; print qq|<APPLET code = "clippedHouse.class" width = "250" height = "250"> </APPLET>|;
    The script was in the same directory as the Java applet. Where are your files located? I'd bet a dollar that's where the problem is - does the applet reference other class files, by any chance?

    Jeff

    R-R-R--R-R-R--R-R-R--R-R-R--R-R-R--
    L-L--L-L--L-L--L-L--L-L--L-L--L-L--
    
Re: cannot load applet using Perl/CGI
by dws (Chancellor) on Apr 04, 2001 at 00:31 UTC
    If your Apache's mime.types doesn't include an entry that looks like   application/octet-stream    class (there may be some other extensions listed along with class), then you'll need to add the following to your .htaccess   AddType application/octet-stream .class Without either of these, Apache will get confused about what .class files are, and might try to execute them on the server side. (Your error log suggests this is the case.)

Re: cannot load applet using Perl/CGI
by arturo (Vicar) on Apr 04, 2001 at 00:06 UTC

    Sounds odd indeed ... are you delivering the *exact same* HTML via the CGI and via the static page?

    Evidently, the version generated by your script is describing the applet in such a way as to make it think it's supposed to execute it (which is what you suspect) but if that's not happening with the static HTML the first place to look is in how the <applet> tags look.

    I'd move the applet to a different directory, you may have them in a directory which Apache has marked with the Options +ExecCGI switch.

    Philosophy can be made out of anything. Or less -- Jerry A. Fodor

Re: cannot load applet using Perl/CGI
by cLive ;-) (Prior) on Apr 04, 2001 at 09:06 UTC
    If it works from a static web page, the error is in the HTML created by your CGI script.

    "What I guess is trying to happen is that Apache is trying to 'execute' the applet instead of 'serving' it. "

    Don't confuse yourself. The Perl script serves the web page output from your script, not the applet. The browser then parses the page and requests the applet in a seperate request.

    crazyinsomniac hit the nail on the head. Either use an absolute url (recommended), or use <BASE HREF...> tag to set the directory you want the browser to base all relative uri requests from.

    cLive ;-)

Re: cannot load applet using Perl/CGI
by Hero Zzyzzx (Curate) on Apr 05, 2001 at 05:42 UTC

    This could be your issue. Hard to tell without seeing your code.

    From CGI.pm - a Perl5 CGI Library, the CGI.pm online documentation

    Most HTML tags are represented as lowercase function calls. There are a few exceptions:
    The <param> tag used to pass parameters to an applet conflicts with CGI's own param() method. Use PARAM() instead.