Each time I call the function of my applet with my Java Script, it throws an undefined exception. And my search engine did not help me at all.
here is the link to the site on which I am posting it right now: Host site
Here is my html for inserting an applet:
<object type="application/x-java-applet" id="ClientApp" name="ClientApp" archive="Cal.jar" width="100" height="100"> <param name="code" value="Calendar_Algorithm" /> <param name="mayscript" value="true" /> </object>
And here is my java script code:
function test(){ document.writeln("<p> "+"Test"+" </p>"); try{ var s=document.ClientApp.getGreeting(); document.writeln("<p> First: "+s+" </p>"); }catch(err){ document.writeln("<p>Error Caught 1: "+err.description+"</p>"); } try{ var s=document.getElementById('ClientApp').getGreeting(); document.writeln("<p> Second: "+s+" </p>"); }catch(err){ document.writeln("<p>Error Caught 2: "+err.description+"</p>"); } document.close(); }
I know that it loads the applet because I see gui, and if that helps, this is my init function
public void init() { try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { JLabel lbl = new JLabel(getGreeting()); add(lbl); } }); } catch (Exception e) { System.err.println("createGUI didn't complete successfully"); } }
here is a link to my full code as well as the Code
I got the feeling that the error is incredibly obvious, but I just do not see it.
Any help would be great!
PS Applet class files are now in the signed jar file.
It will also be located in the webapps folder of the tomcat server, but currently I am accessing it as a local file.
source share