1

I have a group of static files (mainly the static files, including css and images, that make up the ExtJS JavaScript framework). This group of static files rarely changes and therefore I decided NOT to include them within the items in the web application's war file. (I.e. I didn't follow the approach recommended by this answer.)

Right now I serve all these static files under /extjs by having the following Context container defined in server.xml:

<Context docBase="/path/to/extjs-4.1.1" path="/extjs" /> 

That "works" so far; still if anyone is able to suggest a better approach please do.

However I can't find a way to add expires HTTP headers to files served by this context.

Any idea how to configure Tomcat7 in this respect?

Community
  • 1
  • 1
Joseph Victor Zammit
  • 14,760
  • 10
  • 76
  • 102

1 Answers1

0

It doesn't appear that Tomcat's default servlet (org.apache.catalina.servlets.DefaultServlet) has a way to do this.

The easiest thing to do would be to create a servlet filter that simply adds the HTTP headers you need to every request. Since the <context> defines a webapp, you can add a WEB-INF/web.xml file to /extjs and load your filter there. Since /extjs is a separate context, your 'real' application won't be affected.

AngerClown
  • 6,149
  • 1
  • 25
  • 28