title: How to create JNLP dynamically and pass arguments using JSP?
body: <p>I know the question might have come before as well but post Java 7u51 there have been significant changes. Since applet is almost dead now I need to convert one of my project's applet to a JNLP file which can be launched on client's machine. Any pointers as to how to do it using JSPs?? Do I need to sign JNLP and jars dynamically as well?? I am currently working on Java 7u80.</p>
  
  <pre><code>&lt;%@page pageEncoding="UTF-8"%&gt;
  &lt;%@page contentType="application/x-java-jnlp-file" %&gt;
  &lt;%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%&gt;
  &lt;%@taglib uri="/WEB-INF/security.tld" prefix="sec" %&gt;
  
  &lt;%
  
  response.setHeader("Cache-Control", "no-cache");
  response.setHeader("Pragma", "no-cache");
  response.setDateHeader("Expires", -1);
  response.setContentType("application/x-java-jnlp-file");
  
  
  String strFileName = (String) request.getAttribute("FileName");
  HttpSession objHttpSession = request.getSession(false);
  String strSessionId =    (String)objHttpSession.getAttribute(MWIConstants.SESSION_ID);
              if (!(objHttpSession.getId().equalsIgnoreCase(strSessionId)) || null == objHttpSession.getAttribute(MWIConstants.HELPER))
              {%&gt;
                  &lt;logic:redirect forward="LOGIN"/&gt;
              &lt;%}
  
  
  %&gt;
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;jnlp spec="1.7+" codebase="http://localhost:8080/xyz/" href="appletjnlp.jsp"&gt;
  
  &lt;information&gt;
  &lt;title&gt;ImageViewer&lt;/title&gt;
  &lt;vendor&gt;Oracle and/or its affiliates.&lt;/vendor&gt;
  &lt;/information&gt;
  
  &lt;resources&gt;
  &lt;j2se version="1.7+" href="http://java.sun.com/products/autodl/j2se"   max-heap-size="256m"/&gt;
  &lt;jar href="pages/applet/applet.jar"/&gt;
  &lt;jar href="pages/applet/one.jar"/&gt;
  &lt;jar href="pages/applet/two.jar"/&gt;
  &lt;jar href="pages/applet/three.jar"/&gt;
  &lt;jar href="pages/applet/four.jar"/&gt;
  &lt;jar href="pages/applet/five.jar"/&gt;
  &lt;jar href="pages/applet/six.jar"/&gt;
  &lt;jar href="pages/applet/seven.jar"/&gt;
  &lt;/resources&gt;
  
  &lt;applet-desc
  documentbase="http://localhost:8080/mwi/pages/"
  name="ImageViewer"
  main-class="cdac.medinfo.mwt.imaging.imageviewer.ImageApplet"
  width="300" 
  height="300"&gt;
          &lt;param name='targetVersion' value='1.7'&gt;
          &lt;PARAM name="boxbgcolor" value='silver'&gt;
          &lt;PARAM name="progressbar" value='true'&gt;
          &lt;PARAM NAME="FileName" VALUE='&lt;%= strFileName %&gt;'&gt;
          &lt;PARAM NAME="ContextPath" VALUE='&lt;%= request.getContextPath()%&gt;'&gt;
          &lt;PARAM NAME="ResponseObject" VALUE='&lt;%=response%&gt;'&gt;
          &lt;PARAM NAME="ServerName" VALUE='&lt;%=request.getServerName()%&gt;'&gt;
          &lt;PARAM NAME="Port" VALUE='&lt;%= request.getServerPort()%&gt;'&gt;
   &lt;/applet-desc&gt;
  
   &lt;security&gt;
   &lt;all-permissions/&gt;
   &lt;/security&gt;
  
   &lt;component-desc/&gt;
   &lt;/jnlp&gt; 
  </code></pre>