javatomcathippocms

How to configure which file extensions are served statically by Tomcat


In an existing java web app hosted on a Tomcat 6 server, I noticed that all URLs finishing with some specific extensions like .png or .gif are served statically whereas if I replace the extension by something more exotic like .eot then it gets handled by a servlet.

Where is this list of file extensions configured? I checked in web.xml and server.xml but did not find any mention to png or gif.


Solution

  • Well, in fact my problem was specific to Hippo CMS / Bloomreach Experience configuration (which is used in my project). It required to add an .eot to the list of hst:suffixexclusions property under /hst:hst/hst:hosts node, as described in HippoCMS - Request Handling - Mount Matching.

    You can also instead add exlusion rules into site/src/main/webapp/WEB-INF/hst-config.properties file:

    filter.prefix.exclusions = /ping/, /fonts/
    filter.suffix.exclusions = .eot, .woff, .woff2
    

    This will solve the issue that Tomcat is returning HTTP 404 error code on most of font files.