为什么JavaScript调用applet的runtime方法报安全异常?怎么解决?(applet已签名)

zbajm zbajm 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
在下面的代码中,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>

...全文

相关推荐

评论
收藏 已收藏
分享
返回顶部
zbajm
Web 开发 81,108 成员 341,721 内容