473,799 Members | 3,822 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Jul 17 '05 #1
1 6664
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 <mi****@dplanet .chDELETE> wrote in message news:<3f******* *@news.tiscalin et.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>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

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

54
8978
by: Jerry | last post by:
What are the advantages and disadvantages of using Object Oriented PHP vs Java?
0
2585
by: Phil Powell | last post by:
URL: http://valsignalandet.com/cookiegrab.php?name=valIdentifier This page produces a cookie value and sends it back as HTML using PHP and Javascript to obtain it. This URL will be used as the value for a URLConnection object in a Java class to obtain the results of this page to get, of all things, a cookie value. Simply put: it's the ONLY way I know of where I can use Java to ultimately obtain a cookie since this is an application...
2
6929
by: Eyal | last post by:
Hey, I would appriciate if anyone can help on this one: I have a java object/inteface having a method with a boolean parameter. As I'm trying to call this method from a javascript it fails on a type mismatch. It is positively because of the boolean(java primitive)parameter. It goes fine if I change this parameter to int or String. This inteface has a lot more methods which works fine, it is just the
2
1578
by: annie | last post by:
Hi all. Can Java classes/objects be used from within the javascript code on the HTML page? I.e., can I call a Java method from the javascript function? Thanks in advance Anna
4
4057
by: Khan | last post by:
hi, i'm writing java code inside <body> tag of java script file. all the java code is executing at frame startup. how can i call that java code only when i click on a button. I can call jscript function on button click , but i want to call java code on button click. advise some solution.
6
14455
by: rohayre | last post by:
Im a long time java developer and actually have never done anything with java scripting. I'd like to write a short simple script for calculating a date in the future based on today's date and a letter. Can I use javascripting to create a webpage to allow a user to enter a letter and then click a button to find a future calendar date? I'm just not sure how much user interaction scripting allows. Does java scripting allow buttons, textfields...
9
41722
by: misdst23 | last post by:
Hi, I know I can call a static java method within javascript by using the <% ... %tags. But how can pass a javascript variable ? function thefunction() { var = javascriptvariable ;
7
402
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I access a property of an object using a string? ----------------------------------------------------------------------- There are two ways to access properties: the dot notation and the square bracket notation. What you are looking for is the square bracket notation in which the dot, and the identifier to its right, are replaced with a set of...
6
3563
by: Adam Donahue | last post by:
As an exercise I'm attempting to write a metaclass that causes an exception to be thrown whenever a user tries to access 'attributes' (in the traditional sense) via a direct reference. Consider: class X( object ): y = 'private value' def get_y( self ): return self.y
0
10488
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10237
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6808
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5588
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.