Access Java methods from JavaScript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael

    Access Java methods from JavaScript

    Hallo

    I have the following problem:
    Within a web application I have to access the Java methods from
    JavaScripts. I'm using Sun's Java virtual machine version 1.3.1.
    Webbrowser is Microsoft Internet Explorer 5.0

    Now the JSP:
    <html>
    <head>
    <title>WebRAOAp plet Tester</title>
    </head>
    <body>
    <h1>HelloWorl d Test</h1>
    <%
    String codebase = request.getCont extPath();
    %>
    <h3>Variante 1</h3>
    <!--"CONVERTED_APPL ET"-->
    <!-- HTML CONVERTER -->
    <OBJECT classid="clsid: CAFEEFAC-0013-0001-0000-ABCDEFFEDCBA"
    WIDTH="150" HEIGHT="100" NAME="TestApple t1" ID="TestApplet1 "
    ALT="Scheisse!! !"
    codebase="http://java.sun.com/products/plugin/1.3.1/jinstall-131-win32.cab#Versi on=1,3,1,0">
    <PARAM NAME = CODE VALUE = "com.baltimore. webrao.FirstApp let.class" >
    <PARAM NAME = CODEBASE VALUE = "<%= codebase %>" >
    <PARAM NAME = NAME VALUE = "TestApplet 1" >
    <PARAM NAME="type"
    VALUE="applicat ion/x-java-applet;jpi-version=1.3.1">
    <PARAM NAME="scriptabl e" VALUE="false">
    </OBJECT>
    <!--
    <APPLET CODE = "com.baltimore. webrao.FirstApp let.class" CODEBASE
    = "<%= codebase %>" WIDTH = 150 HEIGHT = 100 NAME = "TestApplet " ALT =
    "Scheisse!! !">
    </APPLET>
    -->
    <!--"END_CONVERTED_ APPLET"-->

    <br>
    <a href="javascrip t:void(print1() )"
    onMouseOver="to p.status='Print '; return true">Print</a>
    &nbsp;&nbsp;&nb sp;
    <a href="javascrip t:void(printStr ing1('gugus'))"
    onMouseOver="to p.status='Print String'; return true">PrintStri ng</a>

    <br><hr width="80%"><br >

    <h3>Variante 2</h3>
    <applet CODE = "com.baltimore. webrao.FirstApp let.class" CODEBASE =
    "<%= codebase %>" WIDTH = 150 HEIGHT = 100 NAME = "TestApplet 2" ALT =
    "Scheisse!! !"></applet>
    <br>
    <a href="javascrip t:void(print2() )"
    onMouseOver="to p.status='Print '; return true">Print</a>
    &nbsp;&nbsp;&nb sp;
    <a href="javascrip t:void(printStr ing2('gugus'))"
    onMouseOver="to p.status='Print String'; return true">PrintStri ng</a>

    </body>
    </html>

    <script language="JavaS cript">

    function print1() {
    document.TestAp plet1.print();
    }

    function printString1(ms g) {
    document.TestAp plet1.printStri ng(msg);
    }

    function print2() {
    document.TestAp plet2.print();
    }

    function printString2(ms g) {
    document.TestAp plet2.printStri ng(msg);
    }

    </script>

    Variant 2 (Microsoft VM) does work without any problems but Variant 2
    throws the following error:
    "Object doesn't support this property or method"

    Can anyone help me? In advance thank you very much

    Regards
    Michael

  • Tarken

    #2
    Re: Access Java methods from JavaScript

    The answer is in the error message, as far as I can tell.
    I would guess that Microsoft's VM is autocasting, while Sun's
    VM is not. I haven't done much Javascript, but maybe this would
    work:

    ((com.baltimore .webrao.FirstAp plet)document.T estApplet1).pri ntString(msg)

    regards

    Andre

    Michael <mike-i@dplanet.chDEL ETE> wrote in message news:<3f9aa28c_ 2@news.tiscalin et.ch>...[color=blue]
    > Hallo
    >
    > I have the following problem:
    > Within a web application I have to access the Java methods from
    > JavaScripts. I'm using Sun's Java virtual machine version 1.3.1.
    > Webbrowser is Microsoft Internet Explorer 5.0
    >
    > Now the JSP:
    > <html>
    > <head>
    > <title>WebRAOAp plet Tester</title>
    > </head>
    > <body>
    > <h1>HelloWorl d Test</h1>
    > <%
    > String codebase = request.getCont extPath();
    > %>
    > <h3>Variante 1</h3>
    > <!--"CONVERTED_APPL ET"-->
    > <!-- HTML CONVERTER -->
    > <OBJECT classid="clsid: CAFEEFAC-0013-0001-0000-ABCDEFFEDCBA"
    > WIDTH="150" HEIGHT="100" NAME="TestApple t1" ID="TestApplet1 "
    > ALT="Scheisse!! !"
    > codebase="http://java.sun.com/products/plugin/1.3.1/jinstall-131-win32.cab#Versi on=1,3,1,0">
    > <PARAM NAME = CODE VALUE = "com.baltimore. webrao.FirstApp let.class" >
    > <PARAM NAME = CODEBASE VALUE = "<%= codebase %>" >
    > <PARAM NAME = NAME VALUE = "TestApplet 1" >
    > <PARAM NAME="type"
    > VALUE="applicat ion/x-java-applet;jpi-version=1.3.1">
    > <PARAM NAME="scriptabl e" VALUE="false">
    > </OBJECT>
    > <!--
    > <APPLET CODE = "com.baltimore. webrao.FirstApp let.class" CODEBASE
    > = "<%= codebase %>" WIDTH = 150 HEIGHT = 100 NAME = "TestApplet " ALT =
    > "Scheisse!! !">
    > </APPLET>
    > -->
    > <!--"END_CONVERTED_ APPLET"-->
    >
    > <br>
    > <a href="javascrip t:void(print1() )"
    > onMouseOver="to p.status='Print '; return true">Print</a>
    > &nbsp;&nbsp;&nb sp;
    > <a href="javascrip t:void(printStr ing1('gugus'))"
    > onMouseOver="to p.status='Print String'; return true">PrintStri ng</a>
    >
    > <br><hr width="80%"><br >
    >
    > <h3>Variante 2</h3>
    > <applet CODE = "com.baltimore. webrao.FirstApp let.class" CODEBASE =
    > "<%= codebase %>" WIDTH = 150 HEIGHT = 100 NAME = "TestApplet 2" ALT =
    > "Scheisse!! !"></applet>
    > <br>
    > <a href="javascrip t:void(print2() )"
    > onMouseOver="to p.status='Print '; return true">Print</a>
    > &nbsp;&nbsp;&nb sp;
    > <a href="javascrip t:void(printStr ing2('gugus'))"
    > onMouseOver="to p.status='Print String'; return true">PrintStri ng</a>
    >
    > </body>
    > </html>
    >
    > <script language="JavaS cript">
    >
    > function print1() {
    > document.TestAp plet1.print();
    > }
    >
    > function printString1(ms g) {
    > document.TestAp plet1.printStri ng(msg);
    > }
    >
    > function print2() {
    > document.TestAp plet2.print();
    > }
    >
    > function printString2(ms g) {
    > document.TestAp plet2.printStri ng(msg);
    > }
    >
    > </script>
    >
    > Variant 2 (Microsoft VM) does work without any problems but Variant 2
    > throws the following error:
    > "Object doesn't support this property or method"
    >
    > Can anyone help me? In advance thank you very much
    >
    > Regards
    > Michael[/color]

    Comment

    Working...