jspamazon-cloudfrontservlet-filtershttp-content-length

Why aren't my JSP pages outputting a content-length?


I have configured CloudFront in front of my web application that uses JSP pages, but it will not cache my page because the Content-Length header is not set.

Is there a way that I can get JSP to include the Content-Length, or do I need to do something ugly like have a filter than streams the content to determine it's length, then streams it to the response stream afterwards (setting the ContentLength header first).


Solution

  • I have found a way to do this by using a filter which works well for my needs, I even process the JSP first to remove whitespaces then chain the result of that into the ContentLengthFilter.