0

I am creating a jnlp file but I need to receive some URL parameters.

I have a method that captures the URL from a jsp file:

String getParameter (HttpServletRequest request, String param)

The problem is how to add parameters to the jnlp file:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0" codebase="https://localhost:8443/java-web-start/test/" href="start.jnlp">

    <information>
        <title>TestApp</title>
        <vendor>Oracle</vendor>
        <offline-allowed/>
    </information>
    <security>
        <all-permissions/>
    </security>
    <resources>
        <java version="1.5+"/>
        <jar href="start.jar" main="true"/>
    </resources>
    <application-desc main-class="com.Main"/>
</jnlp>

Here's the index.jsp file:

<%!
    String getParameter(HttpServletRequest request, String param) {
        String result = request.getParameter(param);
        return result.replace("&", "&amp;").replace("\"", "&quot;").replace("<", "&lt;").replace(">", "&gt;").replace("'","$#039;");
    }
%>

<%=getParameter(request, "requestURL")%> 

I want this in my jnlp File and then Download and execute:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0" codebase="https://localhost:8443/java-web-start/test/" href="start.jnlp">

    <information>
        <title>TestApp</title>
        <vendor>Oracle</vendor>
        <offline-allowed/>
    </information>
    <security>
        <all-permissions/>
    </security>
    <resources>
        <java version="1.5+"/>
        <jar href="start.jar" main="true"/>
    </resources>

    <application-desc main-class="com.Main">
        <argument><%= clientCount %></argument>
        <argument><%=getParameter(request, "requestURL")%></argument>
    </<application-desc>
</jnlp>
António Ribeiro
  • 4,129
  • 5
  • 32
  • 49
skynetAI
  • 5
  • 4
  • Why don't you load you `jnlp` and append the `argument`s you want, treating the `jnlp` file as a simple XML file that it is? Look at [this](http://stackoverflow.com/questions/6445828/how-do-i-append-a-node-to-an-existing-xml-file-in-java) example on how to append nodes on XML. – António Ribeiro Feb 15 '16 at 17:55
  • Thank you, now it works, I generate the File as simple XML. – skynetAI Feb 15 '16 at 19:56
  • If it's ok with you, I'm going to post my comment as an answer. – António Ribeiro Feb 15 '16 at 20:49

1 Answers1

0

Load your jnlp and append the arguments you want, treating the jnlp file as a simple XML file that it is.

Take a look at this example on how to append nodes on XML.

Community
  • 1
  • 1
António Ribeiro
  • 4,129
  • 5
  • 32
  • 49