Question

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.

  • Does this feature exists in servlet api 3.0?
  • Does this feature exists in tomcat 7.0?
  • Is there another way to have jsp-files in /lib/*.jar files?
Was it helpful?

Solution

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

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