Hi, We run a website from a ROOT.war file. It also requires some static resources which are in another webapplication (themes) and user uploaded content which is not in source control.
Currently we use apache httpd to serve these 2 directories. The user content is mounted from a fileserver, the themes are checked out on disk directly from scm. The main webapp knows where the files reside on disk so it would be really nice if we could forward the requests for the static resources to the DefaultServlet in tomcat. It's possible if we put 2 <Context> elements in every tomcat's server.xml, but that doesn't feel good since it would require us to specify the location of the files twice (one time in the configuration of the main webapp and one time in the Context element on each tomcat host). Looking at DefaultServlet source code I think it's possible to inject a ProxyDirContext through the ServletContext, which we could modify at webapp init to serve resources from the directories configured in the main webapp. Didn't try this because it feels hacky and would make our app tomcat-dependent. Any ideas on how to go with this? What looks perfect to me is something like this in a ServletFilter; doFilter(Request request, Response response) { String configDir = our.Config.get("themesdir"); File themesDir = new File(configDir); Servlet s = getDefaultServlet(themesDir); s.service(request, response); } Thanks, Robbert-Jan Roos