How to add response headers based on Content-type; getting Content-type before the response is commi
        Posted  
        
            by Bozho
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Bozho
        
        
        
        Published on 2010-04-01T20:10:48Z
        Indexed on 
            2010/04/01
            20:53 UTC
        
        
        Read the original article
        Hit count: 243
        
I want to set the Expires header for all image/* and text/css. I'm doing this in a Filter. However:
- before calling chain.doFilter(..)the Content-type is not yet "realized"
- after calling chain.doFilter(..)the Content-type is set, but so is content-length, which forbids adding new headers (at least in Tomcat implementation)
I can use the extensions of the requested resource, but since some of the css files are generated by richfaces by taking them from inside jar-files, the name of the file isn't x.css, but is /xx/yy/zz.xcss/DATB/....
So, is there a way to get the Content-type before the response is committed.
© Stack Overflow or respective owner