RequestDumperValve dump's the request and the response. So the request is first and the response follows the double dash line for that request.
Tim Funk though pointed out the problem. "You probably can't set headers after doChain() because the response was committed." See his entire message for more details. For now my filter works, I will just have to use setHeader instead of addHeader and be happy with it being called twice. Keith -----Original Message----- From: Shapira, Yoav [mailto:[EMAIL PROTECTED] Sent: Friday, July 30, 2004 9:28 AM To: Tomcat Users List Subject: RE: How do you set cache-control for static (gif, jpg) resources Hola, How's the RequestDumperValve useful, if what you want to inspect are the response headers? Unless you're sending the response to another Tomcat server and this is the RequestDumperValve's log from that second server? Yoav Shapira Millennium Research Informatics >-----Original Message----- >From: Keith Bottner [mailto:[EMAIL PROTECTED] >Sent: Friday, July 30, 2004 9:59 AM >To: 'Tomcat Users List' >Subject: RE: How do you set cache-control for static (gif, jpg) resources > > > >Unfortunately HttpServletResponse has now way to query the headers only to >set them and determine if they exist. However I have the RequestDumperValve >for both editions of the code. Here is the log for the 1st set of code >(your suggestions). > > >: --------------------------------------------------------------- >: authType=BASIC >: contentLength=659 >: contentType=image/gif >: header=Pragma=No-cache >: header=Cache-Control=no-cache >: header=Expires=Wed, 31 Dec 1969 18:00:00 CST >: header=ETag=W/"659-1091194009140" >: header=Last-Modified=Fri, 30 Jul 2004 13:26:49 GMT >: message=null >: remoteUser=username >: status=200 >: scheme=http >: serverName=localhost >: serverPort=8080 >: servletPath=/common/inject/emp-ui-bg-con-tl.gif >: isSecure=false >: --------------------------------------------------------------- >: --------------------------------------------------------------- >: authType=BASIC >: contentLength=7675 >: contentType=image/gif >: header=Pragma=No-cache >: header=Cache-Control=no-cache >: header=Expires=Wed, 31 Dec 1969 18:00:00 CST >: header=ETag=W/"7675-1091194009140" >: header=Last-Modified=Fri, 30 Jul 2004 13:26:49 GMT >: message=null >: remoteUser=username >: status=200 > >Above you can see that none of my changes to the response stream were used. > > >Here is the headers for the 2nd set of code (the original) > >: --------------------------------------------------------------- >: REQUEST URI =/common/inject/emp-ui-bg-con-tl.gif >: authType=BASIC >: characterEncoding=null >: contentLength=-1 >: contentType=null >: contextPath= >: cookie=JSESSIONIDSSO=47372C3C7BB03505C936A20970ACB1F9 >: cookie=JSESSIONID=B75E4FA2AA8047CCD40A885A0A84DFB5 >: header=accept=*/* >: header=accept-language=en-us >: header=accept-encoding=gzip, deflate >: header=user-agent=Mozilla/4.0 (compatible; MSIE 6.0; Windows >NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322) >: header=host=localhost:8080 >: header=connection=Keep-Alive >: header=authorization=Basic ZGhhbHBpbjpkaGFscGlu >: locale=en_US >: method=GET >: pathInfo=null >: protocol=HTTP/1.1 >: queryString=null >: remoteAddr=127.0.0.1 >: remoteHost=127.0.0.1 >: remoteUser=username >: requestedSessionId=B75E4FA2AA8047CCD40A885A0A84DFB5 >: scheme=http >: serverName=localhost >: serverPort=8080 >: servletPath=/common/inject/emp-ui-bg-con-tl.gif >: isSecure=false >: --------------------------------------------------------------- >: --------------------------------------------------------------- >: authType=BASIC >: contentLength=7675 >: contentType=image/gif >: header=Pragma=No-cache >: header=Cache-Control=no-cache >: header=Cache-Control=max-age=1800 >: header=Expires=Wed, 31 Dec 1969 18:00:00 CST >: header=Cache-Control=no-cache >: header=Cache-Control=max-age=1800 >: header=ETag=W/"7675-1091159753343" >: header=Last-Modified=Fri, 30 Jul 2004 03:55:53 GMT >: message=null >: remoteUser=username >: status=200 > > >Do you see the duplicate Cache-Control above? The first >Cache-control=no-cache is the default then my addition then another filter >adds the Expires and then both of the cache control lines are added again. > >Thanks for the performance tip, now if I can just get this! > >I appreciate any help you can offer. > >Keith > >-----Original Message----- > >From: Shapira, Yoav [mailto:[EMAIL PROTECTED] >Sent: Friday, July 30, 2004 8:40 AM >To: Tomcat Users List >Subject: RE: How do you set cache-control for static (gif, jpg) resources > > > >Hi, > >>Previously I was calling doChain at the end of my doFilter method. >> >>Making the change you suggest, calling doChain at the top like ><snip /> >>DOES NOT INSERT any of my changes into the response stream. If I do it >like >>this: ><snip /> >>Then I get two additions in the response stream. >> >>Any more ideas? > >That's a bit strange. Are you wrapping the response or setting these >headers elsewhere? Can you print out to the log a listing of all the >response headers at the end of your filter? > >The addHeader method allows for multiple values, but many readers will only >see the first. So if something in your code sets the cache-control header, >then you call it again, the header will be present twice with two values >(which is legal in the HTTP protocol for most headers). > >As an aside, you can read the enumeration of the init parameters in the >filter's init method, store it in some member variable, and that will >improve the performance of your filter because you won't have to do it on >every request. > >Yoav Shapira > > > >This e-mail, including any attachments, is a confidential business >communication, and may contain information that is confidential, >proprietary and/or privileged. This e-mail is intended only for the >individual(s) to >whom it is addressed, and may not be saved, copied, printed, disclosed or >used by anyone else. If you are not the(an) intended recipient, please >immediately delete this e-mail from your computer system and notify the >sender. Thank you. > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]