为什么JavaScript调用applet的runtime方法报安全异常?怎么解决?(applet已签名)
在下面的代码中,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>
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>
...全文
相关推荐
java javascript 调用命令行 cmd
java javascript 调用cmd命令
c# winform webbrowser页面中js调用winform类方法
在winform嵌入网页项目中,如何在网页中通过js脚本调用winform中类的方法?此demo可以帮到你
Node.js Javascript运行环境(runtime environment)
Node.js是一个Javascript运行环境(runtime environment),发布于2009年5月,由Ryan Dahl开发,实质是对Chrome V8引擎进行了封装。Node.js对一些特殊用例进行优化,提供替代的API,使得V8在非浏览器环境下运行得更好。 V8引擎执行Javascript的速度非常快,性能非常好。 [1] Node.js是一个基于Chrome JavaScript运行时建立的平台, 用于方便地搭建响应速度快、易于扩展的网络应用。Node.js 使用事件驱动, 非阻塞I/O 模型而得以轻量和高效,非常适合在分布式设备上运行数据密集型的实时应用。
vbscript和javascript互相调用方法
vbscript和javascript互相调用方法
firefox applet
firefox不能加载applet


Web 开发
