File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes JavaScript/Applet/JSP problem - please help!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JavaScript/Applet/JSP problem - please help!!" Watch "JavaScript/Applet/JSP problem - please help!!" New topic

JavaScript/Applet/JSP problem - please help!!


Joined: Feb 12, 2002
Posts: 1
Hi everyone,
I'm having a spot of trouble trying to access methods in my applet via javascript on my jsp web page.
I'm embedding the applet into the page with the following code....
<jsp lugin
align="center" width="240" height="241">
<jsp arams>
<jsp aram name="MAYSCRIPT"
value="true" />
</jsp arams>
<p>Sorry, unable to start the applet.</p>
</jsp lugin>
At the browser this then looks like....
OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="240" height="241" align="center" codebase=",2,2,0">
<PARAM name="java_code" value="basicLeftApplet.class">
<PARAM name="type" value="application/x-java-applet;">
<PARAM name="MAYSCRIPT" value="true">
<EMBED type="application/x-java-applet" width="240" height="241" align="center" pluginspage="" java_code="basicLeftApplet.class" MAYSCRIPT="true"
<p>Sorry, unable to start the applet.</p>
Now if you look close enough you'll see that there's no name item in that little lot at all. This is causing me problems as I need a name option to be able to control the applet's methods via JavaScript.
I've tried using document.applets[0].methodName() but that doesn't work, I get an "object doesn't support property or method" error. Embedding the applet manually and using document.appletname.method() seems to work fine.
Can anybody see why the name tag I'm specifying isn't being displayed on the page after processing?
Or even why the document.applets[0].method() gives me the error?
Thanks in advance,
Tran Binh Duong

Joined: Apr 14, 2004
Posts: 1
Originally posted by Tran Binh Duong:

I think the problem is that JavaScript is much faster than Applet.
And when the Applet and Javascrip is run in Browser.
They run in two thread, respectively.
So javaScript reach to the instruction which call a method of the applet before the applet finished starting process.
An Error occur, javascript call a null object.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63849

We're really glad that you are here with us in the JSP forum, and there aren't many rules you'll have to worry about, but one is that proper names are required. Please take a look at the JavaRanch Naming Policy and change your display name to match it.
In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.
JSP Forum Bartender

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: JavaScript/Applet/JSP problem - please help!!
It's not a secret anymore!