you can have a servlet that captures the requests for (certain) filetypes (jnlp).
I've been extending JnlpDownloadServlet in combination with a jsp file that is served as response to the clicked link.
http://docs.oracle.com/javase/1.5.0/docs/guide/javaws/developersguide/downloadservletguide.html
The state has to be preserved by using http get parameters together with the codebase attribute as jnlp file might be downloaded more than once during launch of application. So only way to preserve state is to do it this way afaik.
The state in this example is username and clienttoken.
this is parts of the jsp file i've been using:
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase=<%=request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ request.getContextPath() + "/" %> href="jnlpfile.jnlp?username=<%=request.getParameter("username")%>&clienttoken=<%=request.getParameter("clienttoken")%>">
<information>
<title>title</title>
<vendor>vendor</vendor>
<description kind="short">short desc</description>
<icon href="resources/images/icon.jpg" kind="default"/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<java version="1.7+" java-vm-args="-ea" initial-heap-size="128m" max-heap-size="512m" />
<jar download="eager" href="test.jar"/>
</resources>
<application-desc main-class="test.MainClass">
<argument><%=request.getServerName()%></argument>
<argument><%=request.getParameter("username")%></argument>
<argument><%=request.getParameter("clienttoken")%></argument>
</application-desc>
<update check="background"/>
</jnlp>