By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,557 Members | 1,184 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,557 IT Pros & Developers. It's quick & easy.

Access Java methods from JavaScript

P: n/a
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

Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.FirstApplet)document.TestAp plet1).printString(msg)

regards

Andre

Michael <mi****@dplanet.chDELETE> wrote in message news:<3f********@news.tiscalinet.ch>...
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

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.