Note that there are some explanatory texts on larger screens.

plurals
  1. POGenerate JNLP dynamically
    primarykey
    data
    text
    <p>I need to pass argument to JNLP dynamically for which I tried using a servlet which extends <code>JnlpDownloadServlet</code> and then includes a jsp which has all the JNLP XML written into it.</p> <p>But when I invoke the downloaded JNLP I get <code>BadFieldException</code>.</p> <h2>Servlet</h2> <pre><code>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); } </code></pre> <h2>jnlp.jsp</h2> <p>Used for dumping dynamic JNLP:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;jnlp spec="1.0+" codebase=&lt;%=request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ request.getContextPath() + "/" %&gt; href="test.jnlp"&gt; &lt;information&gt; &lt;title&gt;Demo&lt;/title&gt; &lt;vendor&gt;Sun Microsystems, Inc.&lt;/vendor&gt; &lt;/information&gt; &lt;security&gt; &lt;all-permissions/&gt; &lt;/security&gt; &lt;resources&gt; &lt;j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/&gt; &lt;jar href="lib/test.jar" main="true" /&gt; &lt;/resources&gt; &lt;application-desc name="Dynamic Tree Demo Application" main-class="org.Test" width="300" height="300"&gt; &lt;argument&gt;&lt;%=request.getParameter("arg1")%&gt;&lt;/argument&gt; &lt;argument&gt;&lt;%=request.getParameter("arg2")%&gt;&lt;/argument&gt; &lt;/application-desc&gt; &lt;update check="background"/&gt; &lt;/jnlp&gt; </code></pre> <p>I cannot see the request parameters being received correctly in downloaded JNLP but the above <code>request.getScheme</code> and <code>request.getServerName</code> seem to be working fine. Because of argument value not being received correctly I get <code>BadFieldException</code> when JNLP tries to execute.</p> <p>How to solve this?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload