Applet安全 [英] Applet Security
问题描述
我已经嵌入在访问用户的文件目录的HTML页面的小程序。它的签署。当我写的初始化函数里面code,那么它工作得很好,但是当我写一个方法在这里面code和JavaScript调用它,然后它向我发送安全异常。具有u任何想法我怎么能解决这个问题?
公共类应用扩展javax.swing.JApplet中的{@覆盖
公共无效的init(){
}公共无效callMethod(){
档案文件=新的文件(D:/test.txt);
如果(!file.exists()){
尝试{
file.createNewFile();
}赶上(IOException异常前){
。Logger.getLogger(App.class.getName())日志(Level.SEVERE,空,前);
}
}
}}
使用Javascript:
window.document.applets [0] .callMethod();
请参阅如果回答这个非常类似的问题可以帮助你:<一href=\"http://stackoverflow.com/questions/1068271/signed-applet-gives-accesscontrolexception-access-denied-when-calling-from-java\">signed小程序给出的AccessControlException:拒绝访问,从JavaScript调用时
I have embedded an applet in an html page which access User's file directory. Its signed. When I write code inside init function then it works very well but when I write this code inside a method and call it with Javascript Then it sends me security exception. Have u any idea how can I solve this problem?
public class App extends javax.swing.JApplet {
@Override
public void init() {
}
public void callMethod(){
File file = new File("D:/test.txt");
if(!file.exists()){
try {
file.createNewFile();
} catch (IOException ex) {
Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
Javascript:
window.document.applets[0].callMethod();
See if the answers to this very similar question can help you: signed applet gives AccessControlException: access denied, when calling from javascript
这篇关于Applet安全的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!