display the form print $HTML_FORM; } print $query->stop_html(); This is more or less it - I'm doing something like this in one of my scripts, and it's working reasonably well; there are of course some minor issues you've got to think about, such as: - do you need libraries to include into your classpath? (if yes, you can specify them using the -cp argument to java) - Do you need to get a result from the Java application? Does it print stuff into the console? Does it have a return value? - How long does the application take to execute? In my case, the application can take more than 1 hour to complete, so I fork and inform the user per mail about the result. HTH, Philipp [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => <1071003602.858.20.camel@deepthought> [ref] => [htmlstate] => on_nl2br [postusername] => Philipp Traeder [ip] => philipp@hitchha [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 4 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> Recommendations? - PERL Beginners

Recommendations? - PERL Beginners

Where might I find reference (conceptual) stuff about how to launch a JAVA app via CGI (or vice versa)? Still working it out, but it appears that I may need to get some CGI variables into a JAVA App. Surely this is too difficult to be encapsulated in a website or two? -d...

  1. #1

    Default Recommendations?

    Where might I find reference (conceptual) stuff about how to launch a
    JAVA app via CGI (or vice versa)?
    Still working it out, but it appears that I may need to get some CGI
    variables into a JAVA App.

    Surely this is too difficult to be encapsulated in a website or two?

    -d

    Derek Brinson Guest

  2. #2

    Default Re: Recommendations?

    On Dec 9, 2003, at 2:01 PM, Derek Brinson wrote:
    > Where might I find reference (conceptual) stuff about how to launch a
    > JAVA app via CGI (or vice versa)?
    > Still working it out, but it appears that I may need to get some CGI
    > variables into a JAVA App.
    >
    > Surely this is too difficult to be encapsulated in a website or two?
    My suggestion would be to post this to a Java list, instead of this
    Perl list.

    When you do, go ahead and spell Java correctly, to get off on the right
    foot with them. It's not an acronym, so it doesn't need all those
    capitals. It's just Java.

    Good luck.

    James

    James Edward Gray II Guest

  3. #3

    Default Re: Recommendations?


    On Dec 9, 2003, at 12:01 PM, Derek Brinson wrote:
    [..]
    > Where might I find reference (conceptual) stuff about how to launch a
    > JAVA app via CGI (or vice versa)?
    > Still working it out, but it appears that I may need to get some CGI
    > variables into a JAVA App.
    [..]

    The direction might be of concern.
    You could write a simple piece of Perl
    using the CGI.pm module that would
    launch the Java app, and/or query a
    running one - for that you will want
    a better understanding of CGI.

    May I recommend my own kvetching:
    <http://www.wetware.com/drieux/CS/Proj/TPFH/gen_doc.html>
    Where I try to list the basic reading material that
    will be useful in the 'web and perl' side of the process.

    You are unfortunately correct, the problem of
    web-technologies is not one simple thing in
    one simple place because you have at least
    four issues you have stumbled into

    a. HTTP
    b. HTML/xHTML - for returning to a browser
    c. CGI - the common gateway interface between
    the web-server and your application

    d. Your cgi code and the rest of the code you will
    want to work and play well with.

    If on the other hand, you are hoping to go from
    some Java App to something that would talk to
    a browser, or negotiate in the 'common gateway interface',
    with the web-server - that you will need to go through
    the 'javadocs' for that set of issues.

    But the Perl Side of building the CGI, that we can
    help you with perldoc...

    ciao
    drieux

    ---

    "That which is hateful to you, do not do to your neighbor.
    That is the whole Torah; the rest is commentary. Go and study it."
    - Hillel

    Drieux Guest

  4. #4

    Default Re: Recommendations?

    Hi Derek,

    On Tue, 2003-12-09 at 21:01, Derek Brinson wrote:
    > Where might I find reference (conceptual) stuff about how to launch a
    > JAVA app via CGI (or vice versa)?
    Could you specify what kind of Java application you're talking about?
    The Java *applications* (as opposed to servlets, EJBs etc.) I know can
    be invoked via the command line.
    > Still working it out, but it appears that I may need to get some CGI
    > variables into a JAVA App.
    If it's a normal application, it should be quite easy - something like
    this (roughly sketched and not syntax-checked):

    use CGI;

    my $query = new CGI;

    # this is the actual HTML form - could be out-sourced with
    # HTML::Template or something like that in order not to mix
    # HTML and your code too much
    my $HTML_FORM = <<END
    <form>
    <input type="text" name="java_class_name"/><br/>
    <input type="text" name="argument1"/><br/>
    <input type="submit" name="btn" value="go"/>
    </form>

    END

    # get the parameters from the CGI query
    my $class_name = $query->param('java_class_name');
    my $arg = $query->param('argument1');

    # start printing the response
    print $query->header();
    print $query->start_html();

    # have we been called with parameters (i.e. did the user press the
    button?)
    if ($class_Name) {
    # assemble the command line to execute:
    # you should be able to find the java executable in
    # $JAVA_HOME/bin
    # (this assumes that JAVA_HOME is set, of course, but
    # normally this should be the case)
    my $command = $ENV{'JAVA_HOME'} . '/bin/java ';
    $command .= $main_class . ' ' . $arg;

    # call java to execute your classes "main" method
    my $result = system($command) / 256;

    # print the result to the browser
    print "invoked the java application.<br/>\n";
    print "the result is " . $result . "<br/>\n";
    }
    else {
    # no parameters --> display the form
    print $HTML_FORM;
    }

    print $query->stop_html();

    This is more or less it - I'm doing something like this in one of my
    scripts, and it's working reasonably well; there are of course some
    minor issues you've got to think about, such as:
    - do you need libraries to include into your classpath?
    (if yes, you can specify them using the -cp argument to java)
    - Do you need to get a result from the Java application?
    Does it print stuff into the console? Does it have a return value?
    - How long does the application take to execute? In my case, the
    application can take more than 1 hour to complete, so I fork and inform
    the user per mail about the result.

    HTH,

    Philipp






    Philipp Traeder Guest

  5. #5

    Default Re: Recommendations?

    Derek Brinson wrote:
    > Where might I find reference (conceptual) stuff about how to launch a
    > JAVA app via CGI (or vice versa)?
    > Still working it out, but it appears that I may need to get some CGI
    > variables into a JAVA App.
    >
    > Surely this is too difficult to be encapsulated in a website or two?
    >
    > -d
    Is this a Perl question? If so, can you give us more specifics on what
    you are trying to achieve, and what part you see Pel playing in this?

    Joseph

    R. Joseph Newton Guest

Similar Threads

  1. Recommendations ?
    By michael_eisenman@adobeforums.com in forum Adobe Acrobat SDK
    Replies: 16
    Last Post: January 8th, 09:15 PM
  2. Any recommendations on the...
    By timmytotz in forum Macromedia Director 3D
    Replies: 1
    Last Post: August 31st, 07:42 AM
  3. Hardware Recommendations
    By aaron in forum ASP.NET Web Services
    Replies: 1
    Last Post: August 14th, 12:54 PM
  4. PHP IDE recommendations?
    By Bruce W...1 in forum PHP Development
    Replies: 2
    Last Post: September 16th, 08:40 AM
  5. G5 recommendations??
    By luke in forum Photography
    Replies: 1
    Last Post: August 3rd, 01:25 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139