How to set RESPONSE headers globally using a J2EE container (Websphere)

Is there a way at the web server level (web.xml) to set headers for all transactions? In particular, I would like to do this:

response.setHeader("Cache-Control", "no-cache, no-store"); response.setDateHeader("Expires", -1); 

at the application level. I seem to remember that headers can be set in Web.xml. Are there other solutions?

+4
source share
1 answer

Add a javax.servlet.Filter , write the appropriate logic in the doFilter() method, and finally draw it in web.xml on the url-pattern from /* .

By the way, the set of "magic" that works in all known browsers and proxies is as follows:

 response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1. response.setHeader("Pragma", "no-cache"); // HTTP 1.0. response.setDateHeader("Expires", 0); // Proxies. 
+8
source

All Articles