I have searched and seen a couple of answers about this problem, but still don't know how it's possible...
I'm asked to Implement a filter that returns response-time of an HTTP Request in the response header, eg. response-header: XX in order to get collected by a web analytics client side library.
here's my code :
public void doFilter(ServletRequest request, ServletResponse response,FilterChain chain) throws IOException, ServletException {
HttpServletResponse httpResp = (HttpServletResponse)response;
long startTime = System.nanoTime();
chain.doFilter(request, response);
long endTime = System.nanoTime();
httpResp.addHeader("response-time",endTime-startTime);
}
as well I tried to user HttpServletResponseWrapper
I managed to modify the response using OutputStream but didn't succeed with setting the response headers.
Thanks,Jay