1

I have to delete some temporary file from a users system when he logs out of application. The application has applet. The applet jar is signed. I am following the strategy to call the applet's destroy method to delete files. I am invoking the destroy method of applet by javascript like document.myApplet.destroy() . After invoking this I am getting the error on browser as

Uncaught Error: java.security.AccessControlException: access denied (java.io.FilePermission Uncaught Error: Error calling method on NPObject.

4

2 回答 2

1

Ok I got the answer myself: After refering to this link http://docs.oracle.com/javase/7/docs/api/java/security/AccessController.html , I figured out ,that reading,writing or even deleting can be done by wraping them up in AccessController.doPrivileged method.

AccessController.doPrivileged(new PrivilegedAction() {

                @Override
                public Object run() {
                    try {
                        deleteAppCacheDirectory();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    return null;
                }

            });
于 2013-08-05T10:43:07.777 回答
0

You should remove the call to the destroy method from your javascript code. The destroy method is automatically called by the browser when the user leaves the page. The reason this is happening is probably because your destroy method is not public. This doesn't prevent the browser from calling it, however.

于 2013-08-02T09:43:37.147 回答