Here's an applet that tries to write to a file on a local directory.
You must have a policy file to give this Applet (digital signed Applet) access
to your local file system. This web page is part of a tutorial to demonstrate
a Proof of Concept (prototype) of how a Java Applet can write to a local file.
See the other pages for a full description.
Java Console: Open up the Java console. Messages are written there.
Using JavaScript with Java Plug-in: (works w/IE)
Click
here to run a debugTesting() method in the applet. (Applet embeded in
Java Plugin)
Click
here to have JavaScript write to a local file. (note: Key to make this work is the parm value: param
name = "scriptable" with value = "true" )
Click here
to have JavaScript read the local file and display in an alert box.
Click here to have JavaScript run getDebugProperties().
Using JavaScript with Java (no Plug-in)
Click here
to run a debugTesting() method in the applet. (Applet not embeded.)
Will create a security error: Click
here to have JavaScript write to a local file. (note: Key to make this work is the parm value: param
name = "scriptable" with value = "true" )
Will create a security erorr: Click
here to have JavaScript read the local file and display in an alert box.
Click
here to have JavaScript run getDebugProperties().
Access System Properties from Java:
Important Parm's from HTML to the applet:
<NAME="scriptable" VALUE="true"> - This allows JavaScript
to access the applet embeded in the Plug-in.
<NAME="filename" VALUE="MyAppletWriteFile.txt">
- Name of the file created. Default is "MyAppletWriteFile.txt"
<NAME="pathname" VALUE="c:/temp/"> - Path of the
new file that is created. Default is comes from the user.home System Property
unless specified as in this example.
<NAME="debug" VALUE="true"> - This will automatically
create a file with a default message. Also writes info to the Java Console.
<NAME="debugmsg" VALUE="Hello from an Applet.">
- Message that will be saved in the file.
<NAME="debugproperties" VALUE="true"> - This will
call getDebugProperites which will tell you System Properties. The default
directory is user.home.