Use GAE servlet to serve dynamic JNLP and jar for JavaWS

℡╲_俬逩灬. 提交于 2019-12-08 03:30:41

问题


I encourtered several problems when I try to distribute jar/jnlp dynamically. All my files are dynamically served using http://www.mywebsite.com/ServeFile?name=xxx for file xxx. I can download files correctly.

When I put the link to jnlp in the browser and download, there is an error from javaws showing that the jar file was not found. The GAE log file shows that the javaws tried to load /ServeFile.pack.gz?name=test__V1.0.jar so it wasn't served by the ServeFile servlet, instead it was served by / (which is another servlet)

Here is my jnlp file partial content:

<resources>
    <j2se version="1.6+"/>
    <jar href="ServeFile?name=test.jar" main="true" version="1.0"/>
    <property name="jnlp.packEnabled" value="true"/>
    <property name="jnlp.versionEnabled" value="true"/>
</resources>

My question is how does the javaws put .pack.gz into the middle of the url, instead of just putting a AcceptEncoding in the request? What is the right way to serve jnlp and jar dynamically?

Update

Problem solved when using a "static" type link such as http://website.com/path/file.jar without using ?file=file.jar. I still have a problem:

New Problem

JavaWS will sometimes put ?version-id=1.0 and my dynamic url is also using similar pattern like ?folder=root&user= guest. So version-id would become 1.0?folder=root.

If I put &folder=root&user=guest it would work, but javaws sometimes request myjar__V1.0.jar& folder=root so now the file name has myjar_ V1.0& folder=root which is wrong. It's not consistent.

Temporarily, I can just parse this version-id to see whether it contains a question mark. I hope there is a better solution.


回答1:


On GAE, consider putting the files in the blobstore and using the blobstore service to serve them up.

The Blobstore can serve any binary file

https://developers.google.com/appengine/docs/java/blobstore/overview




回答2:


I got a temporary solution but yet another problem. This jar is stored in datastore, so I need http://www.myserver.com/?file=start.jar to access it. Once I use http://www.myserver.com/start.jar it then works. I just need my servlet to parse the Path instead of getParameter which is still easy.

Problem is with pack.gz and version-id. If you link is http://www.myserver.com/start.jar?folder=root&user=guest then javaws would generate http://www.myserver.com/start.jar.pack.gz?version-id=1.0?folder=root&user=guest for which your getParameter("version-id") is 1.0?folder=root so you possibly think you could use &folder=root&user=guest

But your link could also become http://www.myserver.com/start__V1.0.jar.pack.gz?folder=root&user=guest (which is good). I don't think you can guarantee which one javaws uses so you can't prepare to use ?folder=root or use &folder=root.



来源:https://stackoverflow.com/questions/14108326/use-gae-servlet-to-serve-dynamic-jnlp-and-jar-for-javaws

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!