I am trying to create a Java \"Filter\" which detects a custom HTTP Request Header, and inserts response headers so that the file will download automatically. The response
Try this: set an attribute on the request if the request header is present. Then, check for the attribute after the chain.doFilter(...) and set the response headers then.