我使用JavaScript来执行JNLP,JNLP最终将执行我的客户端。
我正在尝试通过JavaScript执行将参数传递给JNLP,并在我的客户端中通过JNLP获得这些参数。
JavaScript正在执行此URL,例如:
http://localhost:8080/MyJnlp.jnlp?login=14hhh765p&pass=ggyyktff现在,我的JNLP将尝试以这种方式获取<application-desc name tag中的参数:
<application-desc name="..." main-class="com.main.execute" >
<argument>-nosplash</argument>
<argument>-q</argument>
<argument><%=request.getParameter("login")%></argument>
<argument><%=request.getParameter("pass")%></argument>
</application-desc>但它并没有起作用。
我不能以这种方式在我的客户端代码中检索这些参数:
login=getParamsFromJnlp("login")
..
public String getParamsFromJnlp(String key) {
return System.getProperty(key);
}JNLP在APACHE2.2内部
知道出什么问题了吗?
发布于 2012-12-05 20:34:34
为了能够将http参数插入到应用程序的参数中,需要根据请求动态地“构造”.jnlp文件,因为直到那时您才知道将使用哪些http参数。
java-web-start的工作方式是它将多次下载.jnlp,但除了第一次之外,它将从jnlp元素的codebase和href属性中指定的url下载文件。
因此,在元素中动态添加参数元素是不够的,还需要将其添加到codebase/href属性中
<jnlp spec="1.0+"
codebase=<%=request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ request.getContextPath() + "/" %>
href="jnlpfile.jnlp?username=<%=request.getParameter("username")%>&clienttoken=<%=request.getParameter("clienttoken")%>">
...
<application-desc main-class="test.MainClass">
<argument><%=request.getParameter("username")%></argument>
</application-desc>
</jnlp>发布于 2012-12-05 19:07:02
您确定JSP的响应类型是否为"application/x-java-jnlp-file"?
如果没有,请在JSP的顶部注明并检查。
<% response.setContentType("application/x-java-jnlp-file"); %>https://stackoverflow.com/questions/13721587
复制相似问题