jre1.4.2(在JRE1.4.2以上版本中解决Javascript调用已签名Applet方法时提示没有权限问题「终于解决」)

发布时间:2025-12-10 19:49:28 浏览次数:4

在JRE1.4.2以上版本中解决Javascript调用已签名Applet方法时提示没有权限问题「终于解决」-

在JRE1.4.2以上版本中解决Javascript调用已签名Applet方法时提示没有权限问题「终于解决」在JRE1.4.2以上版本中,如果是javascript掉用Applet方法时,即使用户已经信任了这个Applet的签名,还是有可能会出现权限不够的问题,但是如果Applet自己调用方法则没有问题,为此,可以在Applet中的start方法中启动一个线程,这个线程有足够的权限,然后在javascript方法中和这个线程进行交互,以下是代码publicclassMyAppletextends

在JRE1.4.2以上版本中,如果是javascript掉用Applet方法时,即使用户已经信任了这个Applet的签名,还是有可能会出现权限不够的问题,但是如果Applet自己调用方法则没有问题,为此,可以在Applet中的start方法中启动一个线程,这个线程有足够的权限,然后在javascript方法中和这个线程进行交互,以下是代码

public class MyApplet extends Applet {

Thread thread;
String command;
Object result;
boolean isEnd = false;

public void start(){

thread = new Thread(new Runnable() {

public void run(){

while(!isEnd){

try{

synchronized(thread){

thread.wait();
}
}catch(Exception e){e.printStackTrace();}
if(isEnd) return;
try{

if(“CallExe“.equals(command))
result =callExe();
}catch(Exception e){e.printStackTrace();}
synchronized(CardApplet.this){

CardApplet.this.notify();
}
}
}
});
thread.start();
}

public void stop(){

isEnd = true;
synchronized(thread){

thread.notify();
}
}

String call(){

this.command = “CallExe“;
try{

synchronized(thread){

thread.notify();
}
synchronized(this){

wait();
}
}catch(Exception e){

e.printStackTrace();
}
return result;
}

String callExe(){

//todo add logic here
return null;
}

}

需要做网站?需要网络推广?欢迎咨询客户经理 13272073477