• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaScript/Applet/JSP problem - please help!!

 
Chris
Greenhorn
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
type="applet"
code="basicLeftApplet.class"
name="BasicLeftApplet"
align="center" width="240" height="241">
<jsp arams>
<jsp aram name="MAYSCRIPT"
value="true" />
</jsp arams>
<jsp:fallback>
<p>Sorry, unable to start the applet.</p>
</jsp:fallback>
</jsp lugin>
At the browser this then looks like....
OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="240" height="241" align="center" codebase="http://java.sun.com/products/plugin/1.2.2/jinstall-1_2_2-win.cab#Version=1,2,2,0">
<PARAM name="java_code" value="basicLeftApplet.class">
<PARAM name="type" value="application/x-java-applet;">
<PARAM name="MAYSCRIPT" value="true">
<COMMENT>
<EMBED type="application/x-java-applet" width="240" height="241" align="center" pluginspage="http://java.sun.com/products/plugin/" java_code="basicLeftApplet.class" MAYSCRIPT="true"
>
<NOEMBED>
</COMMENT>
<p>Sorry, unable to start the applet.</p>
</NOEMBED></EMBED>
</OBJECT>
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,
Chris
 
Tran Binh Duong
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Tran Binh Duong:
[QB][/QB]

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
Marshal
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Chris",
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.
Thanks!
bear
JSP Forum Bartender
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic