Question

I have a web app: MyApp.war, inside it, I have a jar file: WEB-INF/lib/PublicJar.jar

  • I want client applications to be able to download that jar like a web resource. e.g http://theserver.com/myapp/jars/PublicJar.jar

  • I want the web application to be able to compute the hashcode of the jar file to see if it has changed, so clients know if it needs to reload it.

Can this be done?

Was it helpful?

Solution

Resources inside WEB-INF cannot be served directly to the client. If you want to do that, you need to write a servlet/controller to extract it as a ServletContext resource and feed it to the http response.

Is PublicJar.jar also used by your application itself? Could you not move it out of WEB-INF, or maybe bundle two copies of it in the WAR, one under WEB-INF (for internal application use), and one for downloading?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top