Access Java methods from JavaScript

From: Michael (mike-i_at_dplanet.chDELETE)
Date: 10/25/03


Date: Sat, 25 Oct 2003 18:19:25 +0200

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>WebRAOApplet Tester</title>
   </head>
   <body>
     <h1>HelloWorld Test</h1>
<%
     String codebase = request.getContextPath();
%>
     <h3>Variante 1</h3>
     <!--"CONVERTED_APPLET"-->
     <!-- HTML CONVERTER -->
     <OBJECT classid="clsid:CAFEEFAC-0013-0001-0000-ABCDEFFEDCBA"
WIDTH="150" HEIGHT="100" NAME="TestApplet1" ID="TestApplet1"
ALT="Scheisse!!!"
codebase="http://java.sun.com/products/plugin/1.3.1/jinstall-131-win32.cab#Version=1,3,1,0">
       <PARAM NAME = CODE VALUE = "com.baltimore.webrao.FirstApplet.class" >
       <PARAM NAME = CODEBASE VALUE = "<%= codebase %>" >
       <PARAM NAME = NAME VALUE = "TestApplet1" >
       <PARAM NAME="type"
VALUE="application/x-java-applet;jpi-version=1.3.1">
       <PARAM NAME="scriptable" VALUE="false">
     </OBJECT>
     <!--
       <APPLET CODE = "com.baltimore.webrao.FirstApplet.class" CODEBASE
= "<%= codebase %>" WIDTH = 150 HEIGHT = 100 NAME = "TestApplet" ALT =
"Scheisse!!!">
       </APPLET>
     -->
     <!--"END_CONVERTED_APPLET"-->

     <br>
     <a href="javascript:void(print1())"
onMouseOver="top.status='Print'; return true">Print</a>
     &nbsp;&nbsp;&nbsp;
     <a href="javascript:void(printString1('gugus'))"
onMouseOver="top.status='PrintString'; return true">PrintString</a>

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

     <h3>Variante 2</h3>
     <applet CODE = "com.baltimore.webrao.FirstApplet.class" CODEBASE =
"<%= codebase %>" WIDTH = 150 HEIGHT = 100 NAME = "TestApplet2" ALT =
"Scheisse!!!"></applet>
     <br>
     <a href="javascript:void(print2())"
onMouseOver="top.status='Print'; return true">Print</a>
     &nbsp;&nbsp;&nbsp;
     <a href="javascript:void(printString2('gugus'))"
onMouseOver="top.status='PrintString'; return true">PrintString</a>

   </body>
</html>

<script language="JavaScript">

function print1() {
     document.TestApplet1.print();
}

function printString1(msg) {
     document.TestApplet1.printString(msg);
}

function print2() {
     document.TestApplet2.print();
}

function printString2(msg) {
     document.TestApplet2.printString(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