为什么JavaScript调用applet的runtime方法报安全异常?怎么解决?(applet已签名)
zbajm 2009-03-27 03:31:53 在下面的代码中,applet的init方法可以运行Runtime,而在JavaScript中调用同样的方法却有安全异常,请问各位这么怎么解决这个问题。另外,applet文件已经数字签名。
import java.applet.Applet;
public class MvTelnet extends Applet
{
public static String TELNET = "cmd.exe /c start telnet"; // telnet
public Runtime rt = Runtime.getRuntime();
public void init()
{
super.init();
openWindow(TELNET);
}
public String openWindow(String command)
{
try
{
if (command != null && !command.equals(""))
{
if (rt == null)
{
return "Runtime.getRuntime() == null";
}
rt.exec(command);
return "runtime success";
}
}
catch (Exception e)
{
e.printStackTrace();
return "runtime error : exception";
}
return "command error : " + command;
}
}
<html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
var app = document.applets[0];
alert(app.openWindow(app.TELNET));
</script>
</head>
<body>
<APPLET CODE="MvTelnet.class" width=0 height=0 ARCHIVE="tl.jar"/>
</body>
</html>