-
getting java applet method value in javascript variable
Hi, I have an applet by name TestApp,
import java.applet.*;
import java.io.*;
public class A extends Applet
{
public String line="";
public void init( )
{
String strPath ="D:/WAS_Status.txt";
try
{
BufferedReader objReader = new BufferedReader(new FileReader(strPath));
line = objReader.readLine();
}catch( IOException e)
{
e.printStackTrace();
}
System.out.println("val :"+line);
}
public boolean returnFileValue()
{
if("ON".equals(line))
{
return true;
}
else
{
return false;
}
}
}
In an html :
<HTML>
<HEAD>
<SCRIPT language="JavaScript">
var line='';
function loadAppContent()
{
line=document.TestApplet.returnFileValue();
alert("val : "+line);
}
</SCRIPT>
</HEAD>
<BODY onload="loadAppContent()">
<APPLET CODE="A.class" NAME="TestApplet" >
</APPLET >
</BODY>
</HTML>
But I am not able to get value either as true or false.
line=document.TestApplet.returnFileValue(); Its says object doesnt support this property.
I tried line=document.TestApplet.line; Gets val as undefined.
The line variable of Applet will return either ON or OFF value.
Pls suggest where it has gone wrong?
-
-
I think you can read that describes Java to JavaScript communication at Sun's Java Documentation
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks