使用JSP的动态JNLP

时间:2018-11-13 22:27:27

标签: java jsp jnlp

我有一个JSP文件,当通过超链接调用该文件时会返回JNLP文件。但是,尽管内容是预期的jnlp,但它以jsp(xxx.jsp而不是xxx.jnlp)文件的形式下载。

以下是我的JSP

    <%    
      response.setHeader("Pragma", "no-cache");
      response.setHeader("Expires", "0");
      response.setContentType("application/x-java-jnlp-file");                            
      response.setHeader("Cache-Control", null);
      response.setHeader("Set-Cookie", null);
      response.setHeader("Vary", null);

      // An installer must reply with the version number for a given install
      if (response.containsHeader("x-java-jnlp-version-id"))
        response.setHeader("x-java-jnlp-version-id", "WASClient6.1.0");               
      else
        response.addHeader("x-java-jnlp-version-id", "WASClient6.1.0");
      String codeBase = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ request.getContextPath() + "/";
%>

<?xml version="1.0" encoding="utf-8"?> 
<jnlp spec="1.0+" codebase="<%=codeBase %>">
        <information>
                <title>XXX</title>
        </information>
        <security>
                <all-permissions/>
        </security>
        <resources>

        </resources>
        <application-desc main-class="TestApp">
        </application-desc>
</jnlp>

以下是生成的jsp

 <?xml version="1.0" encoding="utf-8"?> 
<jnlp spec="1.0+" codebase="<%=codeBase %>">
        <information>
                <title>XXX</title>
        </information>
        <security>
                <all-permissions/>
        </security>
        <resources>

        </resources>
        <application-desc main-class="TestApp">
        </application-desc>
</jnlp>

知道我做错了什么吗? 谢谢。

1 个答案:

答案 0 :(得分:0)

您实际上不应该使用scriptlet,但是如果需要,您应该从scriptlet生成jnlp文件,然后执行response.redirect到创建的jnlp文件

Amplify.configure