Results 1 to 4 of 4
  1. #1
    matpen is offline Member
    Join Date
    Feb 2011
    Posts
    3
    Rep Power
    0

    Default calling methods on an applet from cli

    Hi everybody,

    First of all: I am a noob in Java, but not in other programming languages. So, hopefully my question will not sound silly. :)

    I am trying to script some operations which involve dealing with a webserver from my local machine. First, I use wget to download a page which looks like this:

    XML Code:
    <html><head>
    <script type="text/javascript">
    function postModifiedValue(initialValue) {
    var fo = document.formx;
    var modifiedValue = document.loginApplet.getModifiedValue(initialValue);
    fo.modifiedField.value = modifiedValue;
    fo.submit();
    }
    </script>
    </head><body>
    
    <applet code="com.myserver.applets.thisApplet.class" archive="/applets/sha.zip" name="myApplet" WIDTH="1" HEIGHT="1">
    <param name="hashvalue" value="bde95744ec3c92f27b2d">
    </applet>
    
    <form name="fomrx" method="post">
    <input type="hidden" name="modifiedField"/>
    <input type="button" name="send" onclick="return postModifiedValue();" value='Send'/>
    </form>
    
    </body></html>
    Normal usage:
    When this page is displayed in a browser, the JavaVM interprets the applet. When the "send" button is pressed, the javascript function calls a method on the applet, and posts the form back to the webserver together with its return value.

    I would like to automate the "normal usage" so I can perform it from the command line. Of course, I need to interpret the applet from there, so I thought of using the appletviewer (never did before).

    But the question is: can I call a method through the appletviewer and get the result? Or maybe somehow using the "java" command?

    Please note that:
    - I do not have access to the webserver, nor to the source of the applet; I only know that it is some kind of hashing algorithm
    - The returned value depends on the input "initialValue" and on the random "hashvalue" in the param tag

    Many thanks in advance!

  2. #2
    matpen is offline Member
    Join Date
    Feb 2011
    Posts
    3
    Rep Power
    0

    Default

    bump...

    anyone?

  3. #3
    Ruuhkis is offline Member
    Join Date
    Feb 2011
    Posts
    19
    Rep Power
    0

    Default

    Read your code bro.
    You've named your applet myApplet
    name="myApplet" WIDTH="1" HEIGHT="1">
    and you're calling loginApplet
    var modifiedValue = document.loginApplet.getModifiedValue(initialValue );

  4. #4
    matpen is offline Member
    Join Date
    Feb 2011
    Posts
    3
    Rep Power
    0

    Default

    Yeah, sorry 'bout that...

    that's because I rewrote a piece of code from the actual page, to make it more clear, otherwise I had to copy-and-paste a huge portion of it. I corrected it below.

    XML Code:
    <html><head>
    <script type="text/javascript">
    function postModifiedValue(initialValue) {
    var fo = document.formx;
    var modifiedValue = document.myApplet.getModifiedValue(initialValue);
    fo.modifiedField.value = modifiedValue;
    fo.submit();
    }
    </script>
    </head><body>
    
    <applet code="com.myserver.applets.thisApplet.class" archive="/applets/sha.zip" name="myApplet" WIDTH="1" HEIGHT="1">
    <param name="hashvalue" value="bde95744ec3c92f27b2d">
    </applet>
    
    <form name="fomrx" method="post">
    <input type="hidden" name="modifiedField"/>
    <input type="button" name="send" onclick="return postModifiedValue();" value='Send'/>
    </form>
    
    </body></html>

    But the problem remains. Is it possible to call the methods of the applet from the cli? Or from a java program, even if I only have access to the binaries?

    Thanks again...

Similar Threads

  1. Calling methods into another class? Help please!
    By javanator in forum New To Java
    Replies: 1
    Last Post: 03-20-2010, 06:19 PM
  2. Calling for methods
    By soccer_kid_6 in forum New To Java
    Replies: 3
    Last Post: 02-27-2010, 09:12 PM
  3. Calling another applet on click of button in one applet
    By niteshwar.bhardwaj in forum Java 2D
    Replies: 1
    Last Post: 02-19-2009, 12:54 PM
  4. Calling Methods
    By bluegreen7hi in forum New To Java
    Replies: 3
    Last Post: 12-17-2007, 06:22 AM
  5. need help calling methods
    By lowpro in forum New To Java
    Replies: 2
    Last Post: 11-15-2007, 09:53 AM

Posting Permissions

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