wood burning stoves 2.0*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JavaScript/Applet/JSP problem - please help!!" Watch "JavaScript/Applet/JSP problem - please help!!" New topic
Author

JavaScript/Applet/JSP problem - please help!!

Chris
Greenhorn

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
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

Joined: Apr 14, 2004
Posts: 1
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

Joined: Jan 10, 2002
Posts: 60810
    
  65

"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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JavaScript/Applet/JSP problem - please help!!
 
Similar Threads
jsp:param
problem of applet in Netscape 6.2 while usinf JSObject
prolem while calling javascript method from applet in Netscape6.2
Problem while Invoking Applet's method from javascript
problem of JSObject in Netscape6.2