java applet socket_JS 无法调用Java Applet中封装的Public socket方法

在我的页面中有AppletTest.class代码里面有这几个主要的方法:pub...

在我的页面中有

AppletTest.class代码里面有这几个主要的方法:

public void paint(Graphics g){

str=connectionTest("15.50.10.181",3389);

System.out.println("message:"+str);

g.drawString(str, 2, 60);

}

public String connectionTest(String ip, Integer port){

final Integer TIMEOUT = 4000;// ms

String message="";

InetAddress theAddress;

try {

theAddress = InetAddress.getByName(ip);

InetSocketAddress inetSocketAddress = new InetSocketAddress(theAddress, port);

Socket socket = new Socket();

socket.connect(inetSocketAddress, TIMEOUT);

message ="success!";

} catch (UnknownHostException e) {

message="connection timeout1!";

e.printStackTrace();

} catch (IOException e) {

message="connection timeout2!";

System.out.println("connection timeout!");

e.printStackTrace();

}

System.out.println("here is a testReturnAndReadfunction:---"+message);

return message;

}

public String commonTest(String s){

return "test"+s;

}

然后appletTest.jar已经进行self数字签名了,Applet中gaint()方法会自动调用返回结果success, 然后我在JS中用

var message2 =window.document.app.commonTest("JSTest");调用也能返回结果,但是当我用

var message=window.document.app.connectionTest("15.50.10.181",3389);浏览器就会卡死无法执行,

我的问题是为什么connectionTest()方法在类里面调用能执行,但是在JS中调用却执行不了,而其它的方法却能正常执行,在connectionTest()方法里面使用了Socket等功能,用来连接另一台服务器,请问是安全受限问题吗,开始在类里面都执行失败的,后来我用了数字证书之后,在代码能正常执行了,现在的问题是需要申请一个企业级的Publish的证书才能执行吗?

展开

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值