如何使用动态参数启动 Java Web 启动应用程序 [英] How to launch a Java Web start application with dynamic parameters
问题描述
我正在尝试将 Java 小程序迁移到 Java Web 启动应用程序.小程序是从带有多个参数的 JavaScript 激活的,有些参数不是硬编码的 (sessionId
, tempFilePath
):
I'm trying to migrate a Java applet to a Java web start application. The applet was activated from a JavaScript with several parameters, some are not hard-coded (sessionId
, tempFilePath
):
deployJava.runApplet(attributes, parameters);
为了迁移小程序,我使用了一个带有 applet-desc
标记的简单 JNLP 文件.从我调用的 JavaScript 中:
In order to migrate the applet I'm using a simple JNLP file with applet-desc
tag. And from the JavaScript I call:
deployJava.launchWebStartApplication('$jnlp_path');
我只是不明白如何将 JavaScript 创建的参数传递给 Web 启动应用程序.
I just can't understand how to pass to the web start application the parameters that were created by the JavaScript.
推荐答案
好的,原来使用 deployJava.launchWebStartApplication(...)
会触发 Chrome 和 IE 中的安全限制.
我所做的是一种解决方法:我向我的服务器发送了一个 HTTP 请求,服务器的响应是一个 JNLP 内容.
在服务器端,我在运行时编辑 JNLP,每次插入所需的参数.
当浏览器收到 JNLP 内容时,它们会触发下载所需的 jar.
就是这样!
OK, so it turns out that using deployJava.launchWebStartApplication(...)
triggers security restrictions in Chrome and IE.
What I did is kind of work around: I sent an HTTP request to my server and the server's response was a JNLP content.
On the server side, I edited the JNLP on runtime and each time I inserted the required parameters.
When the browsers receive the JNLP content they trigger the download of the required jar.
And that's it!
这篇关于如何使用动态参数启动 Java Web 启动应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!