Poonam,
Thanks for the update. You said that:
The reason I would like to write an applet is that I need to carry out some tests using javascript from a browser and log the results to a file. So a Java application will not do. But i would be runnning these on my local pc so I was wondering if the applet can write to a file in the same folder as where it originated from without going through any security policy issues.
This sounds like you are just doing
testing and have no intention of releasing the applet for use by others, you're just using it on your machine. With that in mind, I have the following suggestion:
Please note: I AM NOT CLAIMING THE FOLLOWING SAMPLE CODE IS SAFE FOR RELEASE. I DO NOT RECOMMEND RELEASING IT. IT IS ONLY FOR YOUR BENEFIT IN TESTING ON YOUR LOCAL MACHINE. With that in mind, I have tested it on a WinNT4.0 machine with Netscape 4.73. (I chose Netscape because you can download it for free and it runs on multiple platforms). The code
does succeed in writing a file to the same folder where the applet originated. Be sure when you compile to include the java40.jar file in your classpath. If you have a recent version of Netscape on your machine, you will have this file. Just do a search for it.
here is the html:
I figured this out using the information in the original link I gave you, as well as this site:
http://developer.netscape.com/index.html?cp=dev01thom When you run the applet, you will get a dialog asking for permission to write to the local file system. If you click the "Grant" button, the file will be written. (I didn't check the other options, but since this is what you are trying to do, I don't know why you would click "Deny".
Anyway, I hope this helps you. Please remember, it's just a quick and dirty program for testing. Please let us know how it goes.
Stephanie