How do I get an Java-Applet to read and write files on the local filesystem?
My Book says it under the control of a Security Manager object which is controlled by the browser. But how do i make it "trust" my applet? (for example by questionening the user)
Thanks in advance!
the user has to set internet security in internet options to allow this. i don't know how you would ask the user for permission and then change it yourself because of the same rights problem. maybe you could somehow detect what the user's security settings were and if they did not allow for file access, just have an error telling them to turn it on.
Most browsers will accept and trust your applet if it is digitally signed with a certificate from Verisign or Thawte. Both Microsoft and Netscape implement this in different ways which means two different certificates. You can find information about signing your applets on their respective developer sites.
Thanks for your ansawers.
To the first one:
Changeing the securityoptions in the browser would be a bad idea right? So every applet could gain access to the filesystem, and I dont think many people would use my applet then.
But anyways, how do you change it in Netscape 4.75? Cant seem to find the option :)
To the second one:
So in order to get it to work I have to BUY two certificates and then it only works on IE and Netscape? The great thing about java is that it works on allmost any platform, so this isnt a "nice" option either I think...
The reason I ask is that I have sometimes seen a box in my browser asking if I would like to "trust" an application
of some website. I thought this was with applets wanting to do things with my filesystem. But this isnt the case?
My problem is that I want the user of my applet to be able to save his or hers work in the program so they can retrieve it later. But its a bit hard to do when you cant write files to their harddrives. Is there really a secutity-problem in letting the user select a file and give the applet access to this file?
But anyways, when I try to write to the file the applet simply doesnt do anything. Why dont I get an IOException or some other error?
I ofcause get an SecurityException and not an IOException...
Seems that you can grant applets access by manipulating some security-files, but it doesnt seem very userfriendly :(
What about going through a CGI script and write/read those files to/from a web server? That what I did in my project!
could you show me the code you used to execute a CGI script from an applet?
URL url = new URL("URL");
URLConnection connection = url.openConnection();
InputStreamReader inStream = new InputStreamReader(connection.getInputStream());
BufferedReader in = null;
in = new BufferedReader(inStream);
............ (read the data from in)
Hope it helps!
p/s: the URL will contain any variable you want to pass in the CGI script (and I believe the you need to encode it too)
[Edited by 123finder.com on 10-19-2000 at 03:03 PM]