On Thu, 2014-03-13 at 21:20 -0400, Martin Gainty wrote: > you'll need to pass your modified response to service method of > servlet which is *in* the filterChain
Utter nonsense. > ApplicationFilterChain::internalDoFilter(ServletRequest request, > ServletResponse response) > throws IOException, ServletException > > { > ............ > servlet.service(request, response); > > ........... > > } > > Martin > > > > > > > > Date: Thu, 13 Mar 2014 17:51:59 -0700 > > Subject: filter question > > From: catph...@catphive.net > > To: users@tomcat.apache.org > > > > I have a filter with doFilter method like this: > > > > public void doFilter(ServletRequest request, > > ServletResponse response, > > FilterChain chain) > > throws IOException, ServletException { > > HttpServletRequest req = (HttpServletRequest) request; > > HttpServletResponse resp = (HttpServletResponse) response; > > > > resp.setHeader("Cache-Control", > > "must-revalidate, max-age=0, post-check=0, > > pre-check=0"); > > > > chain.doFilter(request, response); > > } > > > > This sets the header. However, if I set the header *after* chain.doFilter, > > the header is not set. Why is this? > > > > public void doFilter(ServletRequest request, > > ServletResponse response, > > FilterChain chain) > > throws IOException, ServletException { > > HttpServletRequest req = (HttpServletRequest) request; > > HttpServletResponse resp = (HttpServletResponse) response; > > > > chain.doFilter(request, response); > > > > resp.setHeader("Cache-Control", > > "must-revalidate, max-age=0, post-check=0, > > pre-check=0"); > > } > > > > Programmatically I can see the header is null. > > > > Has the content already been sent to the web browser after chain.doFilter? > > If so, is there a way to delay sending data to the browser? I need to > > inspect the status code in the response before setting my header (to > > prevent 404's from being cached). > > > > Thanks, > > Brendan Miller > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org