Some time ago I read an article what is expected to be in Servlet API 3.0. I remember I read that you can save some .jsp files in a /WEB-INF/lib/somelib.jar/META-INF/web/.jsp and this resources will be exposed to the context root of the web application.
I have just installed Tomcat7 to give it a try, but I found no documentation that I can put some web-resources in jar-files.
JAR files allow us to package multiple files in order to use it as a library, plugin, or any kind of application. On the other hand, WAR files are used only for web applications. The structure of the archives is also different. We can create a JAR with any desired structure.
jar ) contain your executable classes and resource files. A jar can also contain other jar files, which is useful when your program needs some library which is packaged in a jar.
Tomcat JAR deployment options There are three recommended options to make this happen: Package the JAR file in the WEB-INF\lib folder of the Java web application; Place the JAR file in the \lib subfolder of the Apache Tomcat installation; Configure a folder for shared JAR files by editing Tomcat's common.
you can upload the . jar's to /home/tomcat/lib, which is mentioned in this doc. /home/tomcat/lib is added to Tomcat's class loader, so the . jar will be added just like when you put it under CATALINA_HOME/lib."
There is a feature in servlet 3.0 that allows you to package resources (images, jsp, etc.) in a JAR file. What you do is in your jar file, you create META-INF/resources
and dump anything you want in there including directories for structuring your resources. What happens is that META-INF/resources
will be mapped to the docroot
of your web application.
When there is a clash of resource between your app and the JAR file, your apps resource will be returned. See this
Tomcat 7 supports Servlet 3 so it should support this feature
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With