|
By default, browsers do not let applets write to the local file system. This is good thing. Think of the viruses you could write if they let you at the disk. Via a hidden applet you could write just about anything to the PC and the user wouldn't even know it. There are a lot of Java things you can't do from a browser but in some cases the browser has a property to override the default. In that case the user gets a dialog asking if it is okay to do the action. For example, if the applet wants to make a socket connection to a server other than the html server, it must override a property which causes a dialog the user must answer. I don't think file io can be overridden, however. Anyone know for sure? David Wall 553-5329 AS/400 Toolbox for Java "Padmanabhan R (RBIN/ACF)" <Padmanabhan.R@in.bosch.com> on 05/17/2000 10:29:40 AM Please respond to JAVA400-L@midrange.com To: JAVA400-L@midrange.com cc: Subject: File creation Problem Hello , I tried to run the following code , but it is throwing out the security exception. import java.applet.*; import java.awt.*; import java.io.*; public class SimpleSaver extends Applet { public void init() { Button b = new Button("Beans Book"); b.setFont(new Font("System", Font.BOLD, 36)); add(b); Saver f = new Saver(b); } class Saver { public Saver(Button b){ try{ FileOutputStream f = new FileOutputStream("Sav.tmp"); ObjectOutput s = new ObjectOutputStream(f); s.writeObject(b); s.flush(); }catch(Exception e) { e.printStackTrace(); System.out.println(e); } } } } Exception E:\jdk1.2\bin\appletviewer.exe SimpleApplet.html Working Directory - E:\samples\ Class Path - E:\samples\; ;.;d:\Kawa\classes.zip;e:\jdk1.2\lib\tools.jar;e:\jdk1.2\jre\lib\rt.jar;E:\j dk1.2\lib\dt.jar;E:\jdk1.2\jre\lib\jaws.jar;E:\jdk1.2\jre\lib\i18n.jar;E:\jd k1.2\lib\servlet.jar;E:\jdk1.2\lib\as400Driver.jar;i:\proddata\http\public\j t400\utilities\;i:\proddata\http\public\jt400\lib\jt400.jar java.security.AccessControlException: access denied (java.io.FilePermission Sav.tmp write) at java.security.AccessControlContext.checkPermission(Compiled Code) at java.security.AccessController.checkPermission(Compiled Code) at java.lang.SecurityManager.checkPermission(Compiled Code) at java.lang.SecurityManager.checkWrite(SecurityManager.java:946) at java.io.FileOutputStream.<init>(FileOutputStream.java:96) at java.io.FileOutputStream.<init>(FileOutputStream.java:62) at SimpleSaver$Saver.<init>(SimpleSaver.java:26) at SimpleSaver.init(SimpleSaver.java:13) at sun.applet.AppletPanel.run(Compiled Code) at java.lang.Thread.run(Thread.java:479) java.security.AccessControlException: access denied (java.io.FilePermission Sav.tmp write) Process Exit... +--- | This is the JAVA/400 Mailing List! | To submit a new message, send your mail to JAVA400-L@midrange.com. | To subscribe to this list send email to JAVA400-L-SUB@midrange.com. | To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com. | Questions should be directed to the list owner: joe@zappie.net +--- +--- | This is the JAVA/400 Mailing List! | To submit a new message, send your mail to JAVA400-L@midrange.com. | To subscribe to this list send email to JAVA400-L-SUB@midrange.com. | To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com. | Questions should be directed to the list owner: joe@zappie.net +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.