I have been looking for this answer for a long time and have never received a specific solution. So, after that I will finally solve this. I will put the solution below.
Current situation: there was a simple Java application to run from a browser with parameters. The existing route was a browser -> index.html -> calls my jnlp file -> calls the main method of my java class.
Necessary situation: now the user will send arguments, say, the username from the browser, which will be sent before the main method of the java class.
Decision:
- Do not waste time trying to modify only the jnlp file.
Change index.html as follows:
Add getUrlParameters () (google it) function to javascript part of index.html
Get the value of the username with the name usernameParam = getUrlParameters ("username", "," true ")
- Configure this URL = 'nameOfYourJSPFile.jsp? Username = '+ usernameParam
Create a new jsp file (this is required), for example:
<%@ page contentType="application/x-java-jnlp-file" %> <%@ page session="true" %> <% response.setDateHeader ("Expires", 0); //prevents caching at the proxy server // Getting the URL parameters from the request final String USERNAME_PARAM = "username"; String paramUsername = request.getParameter(USERNAME_PARAM); %> <?xml version="1.0" encoding="iso-8859-1"?> <jnlp spec="1.0+" codebase="http://localhost:8080/" href="<nameOfYourJSPFile>.jsp? <%=USERNAME_PARAM + "=" + paramUsername%>"> <information> </information> <security> <all-permissions/> </security> <resources> Your resources... </resources> <application-desc main-class="Complete.package.yourClassNameContainingMain"> <argument><%=paramUsername%></argument> </application-desc> </jnlp>
Once this URL has been generated, you will send it: IFrameDoc.location.replace (URL); in the same index.html
In the String [] argument of the main method, you get the value of the passed username. So, now you can check if the parameter value exists, if so, generate the URL with the jsp file or directly go to the old jnlp file.
source share