动态生成JNLP [英] Generate JNLP dynamically

查看:182
本文介绍了动态生成JNLP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要动态地将参数传递给JNLP,为此我尝试使用一个扩展 JnlpDownloadServlet 的servlet,然后包含一个jsp,其中写入了所有的JNLP XML。 / p>

但是当我调用下载的JNLP时,我得到 BadFieldException



Servlet



  public class TestServlet extends JnlpDownloadServlet {
public void service(ServletRequest req,ServletResponse res)throws ServletException ,IOException {
HttpServletRequest request =(HttpServletRequest)req;
res.setContentType(application / x-java-jnlp-file);
request.getRequestDispatcher(/ jnlp.jsp)。include(request,res);
}



jnlp.jsp



用于转储动态JNLP:

 <?xml version =1.0encoding =UTF-8?> ; 
< jnlp spec =1.0+codebase =<%= request.getScheme()+://+ request.getServerName()+:+ request.getServerPort()+ request.getContextPath ()+/%> HREF = test.jnlp >
< information>
< title>演示< / title>
< vendor> Sun Microsystems,Inc.< / vendor>
< / information>
< security>
< all-permissions />
< / security>
< resources>
< j2se version =1.6+href =http://java.sun.com/products/autodl/j2se/>
< jar href =lib / test.jarmain =true/>
< / resources>
< application-desc name =Dynamic Tree Demo Applicationmain-class =org.Testwidth =300height =300>
< argument><%= request.getParameter(arg1)%>< / argument>
< argument><%= request.getParameter(arg2)%>< / argument>
< / application-desc>
< update check =background/>
< / jnlp>

我看不到在下载的JNLP中正确接收到请求参数,但上述 request.getScheme request.getServerName 似乎工作正常。由于参数值未正确接收,JNLP尝试执行时,我会获得 BadFieldException



如何解决?

解决方案

逻辑上, href =test.jnlp应该是像 href =test.jnlp?arg1 = blah& arg2 = tah



AFAIU JWS客户端将使用JNLP中所述的确切的 coodebase / href 返回服务器。



此外,绝对听取最好的消息。


I need to pass argument to JNLP dynamically for which I tried using a servlet which extends JnlpDownloadServlet and then includes a jsp which has all the JNLP XML written into it.

But when I invoke the downloaded JNLP I get BadFieldException.

Servlet

public class TestServlet extends JnlpDownloadServlet {  
public void service(ServletRequest req, ServletResponse res)  throws ServletException, IOException {  
HttpServletRequest request = (HttpServletRequest) req;
res.setContentType("application/x-java-jnlp-file");
request.getRequestDispatcher("/jnlp.jsp").include(request, res);  
}  

jnlp.jsp

Used for dumping dynamic JNLP:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase=<%=request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ request.getContextPath() + "/" %> href="test.jnlp">
  <information>
   <title>Demo</title>
   <vendor>Sun Microsystems, Inc.</vendor>
  </information>
  <security>
   <all-permissions/>
  </security>
  <resources>
   <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
   <jar href="lib/test.jar" main="true" />
  </resources>
  <application-desc name="Dynamic Tree Demo Application" main-class="org.Test" width="300"   height="300">
       <argument><%=request.getParameter("arg1")%></argument>  
       <argument><%=request.getParameter("arg2")%></argument>
  </application-desc>
  <update check="background"/>
</jnlp>

I cannot see the request parameters being received correctly in downloaded JNLP but the above request.getScheme and request.getServerName seem to be working fine. Because of argument value not being received correctly I get BadFieldException when JNLP tries to execute.

How to solve this?

解决方案

Logically, href="test.jnlp" should be something like href="test.jnlp?arg1=blah&arg2=tah".

AFAIU the JWS client will reach back to the server using the exact coodebase/href stated in the JNLP.

Also, definitely listen to what bestsss has to say.

这篇关于动态生成JNLP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆