|
You could manually edit the codebase on each deployed machine, but there is an easier way. Use a small amount of JSP code to substitute the server name of the request in the right spot of the JSP file.
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.jnlp</url-pattern>
</servlet-mapping>
Next, in your JNLP file, add this at the top to fetch the server name
and port from the request:
<%
String host = request.getHeader("Host");
String http = request.isSecure() ? "https" : "http";
response.setContentType("application/x-java-jnlp-file");
%>
Finally, replace a hardcoded jnlp codebase attribute with one
substituting the host and port from the request
<jnlp codebase="<%=http%>://<%=host%>" ...Now your JNLP file will always reflect the requesting URL, even if your sever is using port redirection or load balancing.
Copyright © 2024 Andrew Oliver