I have a java web application. Here I have some javascript files which I want to be inside a jar file. I want there will be a servlet which will deliver the javascript files from the jar. The feature is like DWR library. They have some javascript files which is not included in the file system. Rather they deliver the javascripts from the jar. DWRServlet class do that. But the path is included in the html header. I want to implement such a feature. Could you guys give me some idea how to implement that
Share
Resources in JARs are part of the classpath. You can get an
InputStreamof a classpath resource byClassLoader#getResourceAsStream(). So, just let your Servlet do exactly that.Assuming that you have those JS resources in
/META-INF/resourcesof the JAR:Then you can get
/META-INF/resources/some.jsof the JAR by http://localhost:8080/contextname/resources/some.js.