Jnlpdownloadservlet and dynamic jnlp file

Problem: we want the version handling (+ jardiff) of JnlpDownLoadServlet, but we also need to construct the jnlp file dynamically (for example: a .jsp file). It seems to me there are two solutions, neither of them good: a) hack the JnlpDownloadServlet (or roll our own), intercepting the jnlp-file-reading code to forward to the jsp page that generates the jnlp xml data and use the generated response as the file contents.
b) generate each jnlp file dynamically and then store it in a temporary location for the JnlpDownloadServlet to pick up. This entails aging the temporary jnlp files and deleting them so the server doesn't get clogged with dead jnlp files.
Is there a third possibility? Or something in the pipe for the near future?
(Note: Web Start Services is not a solution for this task since WSS doesn't support jar versioning, and since the $$properties mechanism does not appear to be ideal for passing a lot of dynamic jnlp information.)
Thanks in advance for any advice.

My jsp page actually generates the list of jars for the application. It also passes some info specific to the user session by means of the jnlp file. Since we are doing games, the list of applications keeps growing. By generating the resource elements dynamically for a game, we can reduce maintenance (as opposed to having a large number of jnlp files with mostly duplicate code) -- especially when a version is updated.
Till we can move to 1.5, I plan to use the temporary file creation method.
Thanks, --John                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • Issue with IE and dynamic JNLP (JSP)

    I'm trying to create a JNLP file using JSP to insert a dynamic argument into the webstarted (new word?) program. The link works fine in Firefox and Opera, but IE throws an error and says that it could not download the file. Here's my setup:
    JSP file (JNLP)
    LaunchClient.jsp
    <%@page contentType="application/x-java-jnlp-file"%>
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE jnlp PUBLIC "-//Sun Microsystems, Inc.//DTD JNLP 1.5//EN" "http://www.netbeans.org/jnlp/DTD/jnlp.dtd">
    <%
        String projectRefID = request.getParameter("projectRefID");
    %>
    <jnlp codebase="http://127.0.0.1:8080/tssa/">
      <information>
        <title>AppTest</title>
        <vendor>Company, Inc.</vendor>
        <homepage href="homepage.html"/>
        <description> </description>
        <icon href="default"/>
        <offline-allowed/>
      </information>
      <resources>
        <j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+"/>
      </resources>
      <resources>
        <jar download="eager" href="jars/AppTest.jar" main="false"/>
      </resources>
      <application-desc main-class="apptest.Main">
        <argument><%= projectRefID %></argument>
      </application-desc>
    </jnlp>My link to the above page looks like this:
    <a href="LaunchClient.jsp?projectRefID=<%=currProject.getReferenceIdentifier()%>" >CLICKME</a>I've added the following mime mappings to my web.xml:
        <mime-mapping>
            <extension>jnlp</extension>
            <mime-type>application/x-java-jnlp-file</mime-type>
        </mime-mapping>
        <mime-mapping>
            <extension>jar</extension>
            <mime-type>application/java-archive</mime-type>
        </mime-mapping>I've also tried using a servlet mapping so the link will still have a .jnlp extension as follows:
      <servlet>
        <servlet-name>JnlpMapping</servlet-name>
        <jsp-file>/restricted/LaunchClient.jsp</jsp-file>
      </servlet>
      <servlet-mapping>
        <servlet-name>JnlpMapping</servlet-name>
        <url-pattern>/restricted/myProgram.jnlp</url-pattern>
      </servlet-mapping>My link then points to myProgram.jnlp instead of LaunchClient.jsp. But that has the same results (works in firefox/opera but not in IE). Does anyone see why IE is complaining? Do I have to break down and write a servlet?
    --Also: I'm using Sun Application Server PE 9
    Message was edited by:
    QSilver002

    I had the same problem. The resolution is preety simple. You can't set header Cache-Control to no-cache, becouse IE tries to cache it before running. That's why any java error occurs, just can't find the file error. What supprised me is that you can't even save the file with right click "Save the target as..", which seems to be little strange. Any other page of type type/html with this header make no problem with that.
    Conclusion:
    IE makes some special trick with a file of type application/x-java-jnlp-file. Cache-Control to no-cache couses not only disability of running the ws directly, but also saving it locally, which doesn't happen with text/html type of page.
    Sevage

  • Dynamic JNLP files?

    I have a number of small, embedded devices running a Cherokee web server, each with their own IP address and hostname. Each of these devices has a standard image that includes a few applets. Is there a way to make a standard JNLP file that could go in the image but would still work? My concern is that the codebase is going to be different for device...

    A way to generate dynamic JNLP's is by using a servlet.
    The servlet path is the JNLP target for the client, and the servlet itself outputs the JNLP contents with the JNLP content-type.
    Jacco

  • Dynamic JNLP file problem

    Okay this topic can be deleted, I'm not sure how to do it myself.
    The problem wasn't Java related at all.
    Thanks.
    Edited by: Cluber on Sep 12, 2011 5:15 PM

    Okay this topic can be deleted, I'm not sure how to do it myself.
    The problem wasn't Java related at all.
    Thanks.
    Edited by: Cluber on Sep 12, 2011 5:15 PM

  • Mapping problem of JnlpDownloadServlet from .Jnlp file

    Hello All,
    1. I am trying to run a java web start application, i am using tomcat 5.5.20 server. I am using the JnlpDownloadServlet to use the $$codebase and $$name to dynimically code the path to the jar's and the jnlp file.
    Here is what i have done:
    Here i have a JnlpDownloadServlet in a seperate folder called (D:/apache-tomcat-5.5.20/webapps/online/server1/WEB-INF/lib/jnlp-servlet.jar).
    2. Now i am placing my .jnlp and my application jar's in a seperate folder called *"client1"* (D:/apache-tomcat-5.5.20/webapps/online/client1/)
    I need to have the client1 and server1 folders and i have to map the servlet to the jnlp file, because i want to keep my jars's and the servlet in a seperate folders.
    3. I have the web.xml file in WEB-INF folder.
    4. web.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app>
    <servlet>
    <servlet-name> JnlpDownloadServlet</servlet-name>
    <servlet-class>jnlp.sample.servlet.JnlpDownloadServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>JnlpDownloadServlet</servlet-name>
    *<url-pattern>../client1/*.jnlp</url-pattern>* *<!-- /* I am having problem here, i think */ -->*
    </servlet-mapping>
    </web-app>
    Myapp.jnlp:
    <?xml version="1.0" encoding="utf-8"?>
    <jnlp spec="1.0+"
    codebase="$$codebase"
    href="$$name">
    <information>
    </information>
    <resources>
    <j2se version="1.6+"/>
    <jar href="$$codebase/XXXXXX.jar" main="true" download="eager"/>
         <jar href="$$codebase/XXXX.jar" download="eager"/>
         <jar href="$$codebase/XXXXX.jar" download="eager"/>
    <nativelib href="$$codebase/XXX.jar" />
    </resources>
    </jnlp>
    While i run the application. i get the following error:
    Error occured when trying to run a Java web start application
    BadFieldException[ The field <jnlp>codebase has an invalid value: $$codebase,$$codebase]
         at com.sun.javaws.jnl.XMLUtils.getAttributeURL(Unknown Source)
         at com.sun.javaws.jnl.XMLUtils.getAttributeURL(Unknown Source)
         at com.sun.javaws.jnl.XMLFormat.parse(Unknown Source)
         at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
         at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
         at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
         at com.sun.javaws.Main.launchApp(Unknown Source)
         at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
         at com.sun.javaws.Main$1.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    I need to resolve the mapping issue, because the servlet is not running and the codebase and href variables are not populated.
    Thanks in Advance.

    Hi Peter,
    to use messages of two different SWCVs in a BPM you need to create a based on relationship between the two SWCVs in SLD. BPM restricts object usage to the SWCV in which the BPM itself resides, so to solve your problem go to the SLD content maintenance and select your SWCV of your BPM, click on Usage Dependencies, then select Define Dependencies, choose Installation Time and then the SWCV in which the other objects reside, click save and your done. You might need to reimport the SWCV to the repository to update the relationship there. It is updated as soon as you can see Basis Objects in the SWCV tree.
    best regards
    Christine

  • Dynamic JNLP and JWS Application Manager

    All,
    I have a Swing application that communicates to the server via Servlets. I have packaged the entire application into a WAR file and I am using JWS to distribute to the users.
    The "main" method of my application accepts two parameters, one of which is dynamic based on information from the web server. To be able to calculate the value of that parameter, I decided to dynamically create and serve my JNLP file through a servlet. The parameter is then passed into the application via the <argument> tag in the served JNLP file.
    That part works great. However, once the application is installed, it doesn't show up in JWS Application Manager. My best guess is because there is not a "physical" JNLP file for reference.
    Can anyone out there confirm or deny my guess? And, more importantly, can anyone give me an idea on how to keep the dynamic JNLP file and get it to install in the JWS Application Manager?
    Thanks!

    Got it fixed. Apparently, the JWS Application Manager "view" setting wasn't correct. Once it was working, the application was showing up fine.

  • JnlpDownloadServlet and WebLogic

    Hi.
    I tried to setup a simple web application following the example1 in the Packaging JNLP Applications in a Web Archive guide.
    I created the war and deploy it on the WebLogic application server but I was unable to launch the jnlp file and got a NullPointerException. (see the stack trace below)
    I was thinking that the servlet was unable to find the jar file in my war, but I'm able to download the jar via direct browsing.
    I'm wondering what the problem might be ?
    regards.
    java.lang.NullPointerException
    at java.io.File.<init>(File.java:181)
    at com.sun.javaws.servlet.DownloadRequest.<init>(DownloadRequest.java:62)
    at com.sun.javaws.servlet.JnlpDownloadServlet.handleRequest(JnlpDownloadServlet.java:94)
    at com.sun.javaws.servlet.JnlpDownloadServlet.doGet(JnlpDownloadServlet.java:86)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)

    We had problems getting JnlpDownloadServlet to work with WebLogic. The reason seems to be that ServletContext.getResource (or some similar method) fails to work if the resource it is trying to access is in a WAR file. We ended up writing a JSP which builds a JNLP file on demand to allow dynamic JNLP files (with attribute substitution, etc.) and not use JnlpDownloadServlet. We tried to write the JSP such that it also served up the JAR files and do versioning ourselves but we ran into the same bug in WebLogic as JnlpDownloadServlet does - getting the same exception as you showed (but with more of a stack-trace as it was within our own code).
    All in all I advise not to use JnlpDownloadServlet and to log a bug with BEA.

  • Download .jnlp file when first time

    Hi Everybody,
    I am new bee for java web start.
    We are having swing application which we want to distribute through Java Web Start. Client can run application through provided web link. we also want to download .jnlp file to the client machine when user clicked the link first time.
    I go through different thread for the above problem in this forum, but though not getting clear idea as in our application, we need to generate dynamic .jnlp file. All solution posted for the above problem assuming that .jnlp file exists at some location, but in our case we have to generate it when user clicked it first time. Any body having some idea ?
    Our second problem is, can it possible that user will run the swing application only when he click the link provided on the web server ? In our case authentication of user is done in our web application and when user will click the provided link user id and other information will be pass to swing application as parameters through .jnlp file. If that application will available offline user can run it through last downloaded .jnlp file without clicking the link , which will be not allowded. Also we are concern about multi user environment, as we are thinking to dynamic generation of .jnlp file , it may possible that other user running the same application noted .jnlp file version difference and will download the .jnlp file of other user ?
    Can any body have any idea, how can we done the above scenario ?
    Thanks in advance,
    Dimpal

    If you upgrade to Java 1.4.2 it will present a dialog asking for desktop
    integration the first time you start the application.
    Maybe that's what you want?

  • Dynamic JNLP causes exception on 1st run after java install

    I have a dynamic JNLP file (php) which runs my software. It works just fine, except for the 1st time it is run after a user has installed Java.
    I get the exception; "The following field was missing from the jnlp file: <jnlp>". When I look at the jnlp code in JWS in the "Launch File" tab of the error message, I see that the JNLP is not there - but the page the user would see if he was not logged into the system (as if JWS has cached the file or something).
    If I close it down, press F5 to refresh, and run it again everything works fine.
    I'm running the dyanmic.jnlp?dummy=randomnumber943934 to prevent caching. In addition, these headers are sent: (php code)
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    // HTTP/1.1
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0", false);
    // HTTP/1.0
    header("Pragma: no-cache");.. so nothing should be cached. But I'm not sure that's where the problem is - cause it only happens the first time after a java install.
    Any clues?

    I think you're dynamicallt created jnlp is invalid in someway; I can use the following without any problems:
    <?php
    header("Content-type: application/x-java-jnlp-file");
    echo "<?xml version=\"1.0\" ?>\n";
    $codebase = trim(stripslashes(urldecode($_REQUEST["codebase"])));
    $href = trim(stripslashes(urldecode($_REQUEST["href"])));
    echo "<jnlp spec=\"1.0+\" codebase=\"$codebase\" href=\"$href\">\n";
    ?>
    </jnlp>
    you should try and test the output of your generated code, something like this should work:
    test.php
    <html>
    <body>
    <textarea rows=20 cols=70>
    <?php
    include 'mydynamicscript.php';
    ?>
    </textarea>
    </body>
    </html>
    The first time a jnlp is called it is downloaded into the browser cache and javaws.exe is executed on it from that location, this in turn downloads the jnlp again from the passed codebase & href attributes into the jws cache. Subsequent calls the jnlp are extracted from the copy in the webstart cache, and often downloaded from the codebase & href attributes when it detects possible changes. In your case these jnlp files seem to differ.
    - Richard

  • Cannot open .jnlp file when asked to open with firefox web browser in ubuntu 11.10 using firefox 6

    After upgrading to ubuntu 11.10 the firefox 6 browser cannot download and open .jnlp file from the interactivebrokers website. Usually I go to the IB website and download tws.jnlp file which is opened in the firefox web browser. But now when I click on the Open with Firefox Browser button, the firefox browser opens a new tab and display the same open window again.

    Seems that after upgrading to 11.10, jnlp files open with firefox instead of javaws (Java Web Start).
    If you right click the file on the download folder and choose "open with" you can manually select java web start.
    Ubuntu bug...
    You can right click any .jnlp file and select "properties", go to "Open With" tab, mark Sun Java 6 Web Start and click "Set as Default". Should fix it. I don't know what would happen if you have the default ubuntu java instead of Sun's. Maybe this wouldn't be necessary.

  • JNLP file version based update like Jar files version?

    Dear All,
    We are using the JWS from the past one year. Its working fine except one or two issues.
    Here i am explaining one of those issues:
    When user double clicks the icon on his desktop, first the JWS checks for updates. If updates found it will download the updates and starts the application.
    JWS doing the updates checking as:
    First its checking the time stamps of the client and server JNLP files. If server JNLP file time stamp is grater than client JNLP file time stamp, then its checks for each and every jar file update.
    For Jar files update we are using the version based. Our JNLP file is as shown below:
    <jnlp spec="1.0" codebase="$$codebase" href="LaunchMedplexus.jnlp">
    <information>
    <title>CBST</title>
    <vendor>CBST</vendor>
    <description kind="short">CBST</description>
    <icon href="../../../../images/image1.gif" kind="splash"/>
    <icon href="../../../../images/image1.jpg"/>
    <offline-allowed/>
    </information>
    <security>
    <all-permissions/>
    </security>
    <resources>
    <j2se version="1.4" initial-heap-size="48m" max-heap-size="256m"/>
    <jar href="../../../../JARS/AppJars/POMS/admin/admin.jar"      version="7.7.0.0" />
    <jar href="../../../../JARS/AppJars/POMS/billing/bil_adj.jar"      version="7.7.0.0" />
    </resources>
    <application-desc main-class="com.test.security.Login">      
    </application-desc>
    </jnlp>
    we are facing the problems because JWS updates checking is based on the JNLP file time stamp.
    is there is any way in JWS to check the updates based on JNLP file version instead of timestamp (like jars version based)?
    Our Environment is :
    JRE : 1.4.2_10
    OS : Windows 2000/XP
    thanks in adavance
    Krishna Mohan.

    Dear Andy,
    Thank You for your reply.
    perhaps you can use a simple jnlp file that referre to almost all of the application using a versioned jnlp component extension.can you explain this line little more elaborately.
    thanks in advance
    km

  • Dynamic generation of jnlp file

    I'm dynamically generating a jnlp file using a jsp to pass run-time parameters over to my Java application thusly:
    <%
    response.setContentType("application/x-java-jnlp-file");
    String userName = request.getParameter("username");
    String password = request.getParameter("password");
    String batchId = request.getParameter("batchid");
    out.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
    out.println("<jnlp ");
    out.println("spec=\"1.0+\" ");
    out.println("codebase=\"http://server/directory\" ");
    out.println("href=\"this jsp file\">");
    ... other jnlp stuff...
    out.println("<application-desc main-class=\"myApp.myClass\">");
    out.println("<argument>" + userName + "</argument>");
    out.println("<argument>" + password + "</argument>");
    out.println("<argument>" + batchId + "</argument>");
    out.println("</application-desc>");
    out.println("</jnlp>");
    And use args[] to attempt to get the passed parameters in the Java application:
    userName = args[0];
    password = args[1];
    batchId = args[2];
    However, they don't seem to be passed over to the application as I get NullPointerExceptions. If I try to trace the state of the arguments by adding:
    FileOutputStream f = new FileOutputStream("w:output.txt");
    BufferedWriter w = new BufferedWriter(new OutputStreamWriter(f, System.getProperty("file.encoding")));
    w.write("userName: " + userName);
    w.write("password: " + password);
    w.write("batchId: " + batchId);
    f.flush();
    f.close();
    The output file is completely empty.
    1. Am I passing the arguments in wrongly?
    2. Why is the output not being written in the file?
    My thanks in advance for any assistance offered.
    Erkton

    Erkton,
    I use a similar approach and it does work. The main gotchas I found were typos. I would suggest temporarily changing the
    response.setContentType("application/x-java-jnlp-file");
    line to
    response.setContentType("text/xml");
    and looking at your JNLP file as XML and verifything that you got everything write. Look for beginning and end tags, stuff like that.
    Once you have it right then switch it back to JNLP.
    One other thing to look out for is Internet Explorer doesn't like jnlp files unless they end with a .jnlp extension. I had to rename my jnlp files to end with .jnlp instead of .jsp for IE to parse them correctly. I don't think thats the issue you are running into, but you may want to look out for it.

  • Dynamically generating the jnlp file

    Hi Experts,
    Im working on a project in which we launch the Eclipse RCP from the web UI (thin client).
    I want to dynamically generate the jnlp file cause I want to pass the session of the user from the web client to RCP.
    So for this i have thought of having a variable let say sessionID ,which will take value of the session
    sum thing like this...
    <application-desc main-class="com.rcp.core.HelloWorld">
    <property name="sessionID" value="$$userSessionId"/>
    </application-desc>
    But im not able to figure out how i will populate the sessionID variable.
    which class should be responsible for doing this?
    whether that class will be in the RCP code or in the Web code...i guess it is in the web code?
    Please if u can clarify these doubts then it will be great.
    Thanks
    ved

    usually you would use jsp or a servlet to generate the jnlp file.
    If you extend the JnlpDownloadServlet (found in the sample directory in the JDK) you can generate the session id.
    /Andy

  • JNLP file not opening in Windows 8 and IE 10

    I am trying to launch the ROES ordering tool through WHCC prints and it has always worked on my other IE 10 through Windows 7 but on my new computer with Win 8 I cannot get it to launch because of the JNLP file not opening... and it won't work on desktop
    mode either... What do I need to do??

    Hi,
    Have you installed the java Runtime Environment?
    If not, I would also suggest you to refer to the link to install the latest version of Java:
    http://www.java.com/en/
    Please note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.
    Then follow the link to set default programs as Java for the file:
    Choose the programs
    Windows uses by default
    http://windows.microsoft.com/en-US/windows-8/choose-programs-windows-uses-default
    Hope this helps,
    Ada Liu
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • How to upload and overwrite a file from a dynamic list

    I need to come up with a way to upload and overwrite and existing image file from a dynamically generated list. For instance, there would be a drop-down select box with Company A, Company B, Company C, etc. and when the user selects one of them it should display a prompt to upload a new logo image file, overwriting the existing logo file. Any help would be appreciated.

    I'm not sure why you need a prompt.  Sounds like an unnecessary annoyance to me.
    A simple form with a select and input type="file" should get you started.  Then I would probably do something like:
    1.  upload the file to a temp folder on your server.
    2.  Rename it according to what company was selected.
    3.  Move it to it's permanent folder.

Maybe you are looking for