The Servlet 3.0 specification defines a way for any JAR in a web application to provide resources that can be accessed via a URL. This is especially useful for tag libraries since the markup generated by tags will require CSS and JavaScript resources to be included in each page a tag is used.

The directory in each JAR that is exposed is 'META-INF/resources'. Any files in this directory are accessible just like resources in the root of the WAR. Which leads to...

JSPs in JARs

JSP files in META-INF/resources also get the special treatment. This allows you to package your application as a set of JARs. This is useful if there are multiple customers and a set of features are customized for each one. The JSPs and action classes that provide the default behavior can be packaged as a shared JAR. The customizations can override the defaults. The servlet spec states that resources in the WAR will override any resources in a JAR when they have the same context relative path.

Example Application

I have created GitHub project that demonstrates web resources in JARs. The application does require a Servlet 3.0 environment such as Tomcat 7. To build the project execute:

mvn package

The application can be accessed at http://localhost:8080/web-app/Index.action.