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("&", "&").replace("\"", """).replace("<", "<").replace(">", ">").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>
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.