• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Servlet filters and static content

Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm producing a filter that modifies the response text of JSP requests. However, I also want to modify included static files such as .css and .js
files. The filter works fine on the output from the JSP's, but doesn't on any .css and .js requests. I can see the .css files and .js files being processed, but the response text they work on is empty.

I'm thinking that the servlet engine doesn't handle static content, and this is why the response for static content is empty.
Is this the case? How are requests to static files served up in Tomcat 6?

Any comments appreciated.
Posts: 20841
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you'll look in the TOMCAT_HOME/conf/web.xml file you'll see the answer.

<!-- ================== Built In Servlet Definitions ==================== -->

<!-- The default servlet for all web applications, that serves static -->
<!-- resources. It processes all requests that are not mapped to other -->
<!-- servlets with servlet mappings (defined either here or in your own -->
<!-- web.xml file. This servlet supports the following initialization -->
<!-- parameters (default values are in square brackets): -->

The actual default servlet itself is defined in the usual way.


If your modifications have anything to do with altering cache control headers, you should know that there are less intrusive ways, however.

And, of course, if you muck around with the DefaultServlet's internals, you'll be working outside the pale of the J2EE standard and the resulting WAR will not be "write once run anywhere".
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!