Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JavaScript/Applet/JSP problem - please help!!  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
Author and ninkuma
Posts: 66425
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!