On Tue, May 24, 2005 1:01 pm, [EMAIL PROTECTED] said: > I haven't tried it, but it appears to me that the cache headers will be > inserted if *any* of the noCachePaths differs from the requested path.
D'oh! I think your right. I actually want something more like this: public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws ServletException, IOException { String path = ((HttpServletRequest)request).getServletPath(); boolean pathInCollection = false; for (Iterator it = noCachePaths.iterator(); it.hasNext();) { String noCachePath = (String)it.next(); if (path.equalsIgnoreCase(noCachePath)) { pathInCollection = true; } } if (!pathInCollection) { ((HttpServletResponse)response).setHeader("Pragma", "No-cache"); ((HttpServletResponse)response).setHeader("Cache-Control", "no-cache,no-store,max-age=0"); ((HttpServletResponse)response).setDateHeader("Expires", 1); } filterChain.doFilter(request, response); } // End doFilter(). > - George Thanks for pointing that out! Oddly enough, it worked in my test case, just a fluke I guess, but wouldn't have for all cases. Good catch! -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com >> -----Original Message----- >> From: Frank W. Zammetti [mailto:[EMAIL PROTECTED] >> Sent: Tuesday, May 24, 2005 11:47 AM >> To: Giovanni Santini >> Cc: dev@struts.apache.org >> Subject: Re: Fwd: RequestProcessor, cache control, IE bug >> >> >> FYI, I solved this with a filter. Pretty simple... I intend >> to load the paths from a config file, but for now this is >> fine. If you want to use it, just remove the nocache setting >> from struts-config and configure this filter in web.xml: >> >> ---------------------------------------------------------------------- >> >> package com.company.app.filters; >> >> import java.io.IOException; >> import java.util.ArrayList; >> import java.util.Iterator; >> import javax.servlet.Filter; >> import javax.servlet.FilterChain; >> import javax.servlet.FilterConfig; >> import javax.servlet.http.HttpServletRequest; >> import javax.servlet.http.HttpServletResponse; >> import javax.servlet.ServletException; >> import javax.servlet.ServletRequest; >> import javax.servlet.ServletResponse; >> >> /** >> * This filter more or less mimics the cachecontrol Struts RP >> setting, but >> * allows you to set paths that cache headers will NOT be set for. >> * >> * @author <a href="mailto:[EMAIL PROTECTED]">Frank W. >> Zammetti</a> */ public class CacheControlFilter implements Filter { >> >> /** >> * List of paths to *NOT* set cache headers on. >> */ >> private ArrayList noCachePaths = new ArrayList(); >> >> /** >> * Destroy. >> */ >> public void destroy() { } // End destroy. >> >> /** >> * Populate the list of paths that cache headers will NOT >> be set for. >> * >> * @param filterConfig The configuration information >> for this filter. >> * @throws ServletException ServletException. >> */ >> public void init(FilterConfig filterConfig) throws >> ServletException { >> noCachePaths.add("/app/path1.do"); >> noCachePaths.add("/app/path2.do"); >> noCachePaths.add("/app/path3.do"); >> } // End init(). >> >> >> /** >> * Set the cache headers to response, where applicable. >> * >> * @param request The current request object. >> * @param response The current response object. >> * @param filterChain The current filter chain. >> * @throws ServletException ServletException. >> * @throws IOException IOException. >> */ >> public void doFilter(ServletRequest request, >> ServletResponse response, >> FilterChain filterChain) >> throws ServletException, IOException { >> String path = ((HttpServletRequest)request).getServletPath(); >> for (Iterator it = noCachePaths.iterator(); it.hasNext();) { >> String noCachePath = (String)it.next(); >> if (!path.equalsIgnoreCase(noCachePath)) { >> ((HttpServletResponse)response).setHeader("Pragma", >> "No-cache"); >> ((HttpServletResponse)response).setHeader("Cache-Control", >> >> "no-cache,no-store,max-age=0"); >> ((HttpServletResponse)response).setDateHeader("Expires", 1); >> } >> } >> filterChain.doFilter(request, response); >> } // End doFilter(). >> >> } // End CacheControlFilter class. >> >> ---------------------------------------------------------------------- >> >> -- >> Frank W. Zammetti >> Founder and Chief Software Architect >> Omnytex Technologies >> http://www.omnytex.com >> >> On Tue, May 24, 2005 11:26 am, Giovanni Santini said: >> > I've to go through the class RequestProcessors >> > And I'lll send other news >> > I think this settings has to be possible overwrite in the >> action with >> > some methods where it'll be possible make this settings >> > Best regards >> > >> > On 5/24/05, Frank W. Zammetti <[EMAIL PROTECTED]> wrote: >> >> >> >> What a freaky coincidence... I just rolled my app into a new >> >> environment last night and was having this exact problem. I didn't >> >> even think of the nocache setting, but sure enough I >> removed it from >> >> my struts-config and now my PDFs are working again. >> >> >> >> I have the same question as you now though. I don't >> *believe* there >> >> is a way to do it per-path within Struts... My idea is to set the >> >> header myself in my base Action, or else create a filter to do it >> >> that knows which paths >> >> to NOT apply it to (since I only have 3-4 like that it's a >> reasonable >> >> solution). >> >> >> >> If you come up with something better, I would very much appreciate >> >> hearing about it though. :) >> >> >> >> -- >> >> Frank W. Zammetti >> >> Founder and Chief Software Architect >> >> Omnytex Technologies >> >> http://www.omnytex.com >> >> >> >> On Tue, May 24, 2005 9:18 am, Giovanni Santini said: >> >> > ---------- Forwarded message ---------- >> >> > From: Giovanni Santini <[EMAIL PROTECTED]> >> >> > Date: May 24, 2005 3:16 PM >> >> > Subject: Fwd: RequestProcessor, cache control, IE bug >> >> > To: dev@struts.apache.org >> >> > >> >> > Hi, >> >> > we have a problem with RequestProcessor when you set >> nocache set to >> >> true >> >> > in >> >> > struts config file. >> >> > It sets in http header the Cache-control parameter, and >> when we try >> >> > to download a pdf it conflicts with a bug of explorer. >> How we can >> >> > have a fine grain in the decision of this parameter in >> our action? >> >> > If I set again the cache-control parameter on the >> action, does it will >> >> > overwrite the value set in requestProcessor? >> >> > Do you know which is the best way to fix this problem? >> >> > In attachment you can find the IE bug! >> >> > Kind regards >> >> > >> >> > "Internet Explorer Cannot Download" Error Message When You Use an >> >> HTTPS >> >> > URL >> >> > to Open an Office Document or PDF File 05/20/2005 09:20 AM >> >> > >> >> > >> http://support.microsoft.com/default.aspx?scid=kb;en-us;812935 Page >> >> > 1 >> >> of >> >> 2 >> >> > >> >> > Article ID : 812935 >> >> > >> >> > Last Review : April 15, 2004 >> >> > >> >> > Revision : 2.0 >> >> > * >> >> > >> >> > "Internet Explorer Cannot Download" Error Message >> >> > >> >> > When You Use an HTTPS URL to Open an Office >> >> > >> >> > Document or PDF File >> >> > >> >> > SYMPTOMS >> >> > * >> >> > >> >> > When you try to open a Microsoft Office document or a PDF file by >> >> > >> >> > typing an HTTPS Uniform Resource Locator (URL) for the >> document on >> >> > >> >> > the Address bar in Internet Explorer 6 Service Pack 1 (SP1), the >> >> > >> >> > document may not open, and you may receive the following error >> >> > >> >> > message: >> >> > >> >> > Internet Explorer cannot download >> >> > *document.pdf *from *server** >> >> > >> >> > CAUSE >> >> > * >> >> > >> >> > This issue may occur if any one or more of the following >> conditions >> >> are >> >> > true: >> >> > >> >> > * >> >> > The *Do not save encrypted pages to disk *check box is >> selected in >> >> > Internet Explorer 6.0 SP1. >> >> > >> >> > * >> >> > The server sends the "Cache-Control: No Store" header. >> >> > >> >> > * >> >> > The server sends the "Cache-Control: No Cache" header.* >> >> > >> >> > RESOLUTION >> >> > * >> >> > >> >> > A supported fix is now available from Microsoft, but it is only >> >> intended >> >> > to >> >> > correct the problem that is >> >> > >> >> > described in this article. Apply it only to computers that are >> >> > experiencing this specific problem. This fix >> >> > >> >> > may receive additional testing. Therefore, if you are >> not severely >> >> > affected by this problem, Microsoft >> >> > >> >> > recommends that you wait for the next Internet Explorer >> 6 service >> >> > pack that contains this fix. >> >> > >> >> > To resolve this problem immediately, contact Microsoft Product >> >> > Support Services to obtain the fix. For a >> >> > >> >> > complete list of Microsoft Product Support Services >> phone numbers >> >> > and information about support >> >> > >> >> > costs, visit the following Microsoft Web site: >> >> > >> >> > http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS >> >> > * >> >> > >> >> > NOTE >> >> > *: In special cases, charges that are ordinarily incurred for >> >> > support calls may be canceled if a >> >> > >> >> > Microsoft Support Professional determines that a specific update >> >> > will resolve your problem. The typical >> >> > >> >> > support costs will apply to additional support questions >> and issues >> >> that >> >> > do >> >> > not qualify for the specific >> >> > >> >> > update in question. >> >> > >> >> > The English version of this fix has the file attributes >> (or later) >> >> that >> >> > are >> >> > listed in the following table. The >> >> > >> >> > dates and times for these files are listed in >> coordinated universal >> >> time >> >> > (UTC). When you view the file >> >> > >> >> > information, it is converted to local time. To find the >> difference >> >> between >> >> > UTC and local time, use the >> >> > * >> >> > >> >> > Time Zone >> >> > *tab in the Date and Time tool in Control Panel. >> >> > >> >> > Date Time Version Size File name >> >> > ---------------------------------------------------------- >> >> > >> >> > 11-Mar-2003 08:42 6.0.2800.1174 585,728 Wininet.dll >> >> > * >> >> > >> >> > WORKAROUND >> >> > * >> >> > >> >> > To work around this problem, make sure that >> >> > *Do Not Save Encrypted Files *check box is not checked >> >> > >> >> > and that the server does not send the "Cache-Control: No >> Store" or >> >> > the >> >> > "Cache-Control: No Cache" >> >> > >> >> > header. >> >> > >> >> > You may also be able to work around this problem by >> using an HREF >> >> > to >> >> load >> >> > the document. >> >> > * >> >> > >> >> > Note >> >> > *This method does not work if the server uses the >> "Cache-Control: >> >> > No Cache" >> >> > header.* >> >> > >> >> > STATUS >> >> > * >> >> > >> >> > Microsoft has confirmed that this is a problem in the Microsoft >> >> products >> >> > that are listed at the beginning >> >> > >> >> > of this article. >> >> > * >> >> > >> >> > APPLIES TO >> >> > * >> >> > >> >> > * >> >> > Microsoft Internet Explorer 6.0 Service Pack 1* >> >> > >> >> > Keywords: >> >> > *kberrmsg kbfix kbhttp kbie600presp2fix kbinetdev kbqfe kbhtml >> >> kbbrowse >> >> > KB812935 >> >> > >> >> > "Internet Explorer Cannot Download" Error Message When You Use an >> >> HTTPS >> >> > URL >> >> > to Open an Office Document or PDF File 05/20/2005 09:20 AM >> >> > >> >> > >> http://support.microsoft.com/default.aspx?scid=kb;en-us;812935 Page >> >> > 2 >> >> of >> >> 2 >> >> > >> >> > (c)2005 Microsoft Corporation. All rights reserved. >> >> > >> >> > On 5/24/05, Joe Germuska <[EMAIL PROTECTED]> wrote: >> >> >> >> >> >> At 10:39 PM -0400 5/23/05, Frank W. Zammetti wrote: >> >> >> >Hey all... I was working with a user who is using >> AjaxTags, and >> >> >> >he raised something that I wanted to check with you guys on... >> >> >> > >> >> >> >What is the difference between struts-html.tld and >> >> >> >struts-html-1.1.tld? The user indicated that the 1.1 version >> >> >> >provides servlet 2.4 compatibility. Is this accurate? >> >> >> >> >> >> No. If you're talking about the files such as can be retrieved >> >> >> from >> http://www.ibiblio.org/maven/struts/tlds/struts-html-1.1.tld >> >> >> , the only reason those have version numbers is because >> they are >> >> >> part of a maven repository. If you look inside the file, you'll >> >> >> see that it has a DTD declaration that looks like this: >> >> >> >> >> >> <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag >> >> >> Library 1.1//EN" " >> >> >> http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd"< >> >> http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd%22> >> >> >> > >> >> >> >> >> >> , while Servlet 2.4 (or rather JSP 2.0 ) TLD files use >> XML Schema >> >> >> and have an opening element that looks like this: >> >> >> >> >> >> <taglib xmlns=" http://java.sun.com/xml/ns/j2ee" xmlns:xsi=" >> >> >> http://www.w3.org/2001/XMLSchema-instance" >> >> >> >> >> >> xsi:schemaLocation=" >> >> http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd >> >> >> " >> >> >> version="2.0"> >> >> >> >> >> >> To be honest, I'm not sure what part of Maven retrieves >> TLD files >> >> >> from the repository, but the surest way to know is to >> look inside >> >> >> the file. >> >> >> >> >> >> However, you can use JSP 2.0 with the non-EL tags with >> no problem. >> >> >> (At least, I haven't had any yet.) >> >> >> >> >> >> Joe >> >> >> >> >> >> -- >> >> >> Joe Germuska >> >> >> [EMAIL PROTECTED] >> >> >> http://blog.germuska.com >> >> >> "Narrow minds are weapons made for mass destruction" -The Ex >> >> >> >> >> >> >> ------------------------------------------------------------------ >> >> >> --- >> >> >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> >> >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> >> >> >> >> >> >> > >> >> > >> >> > -- >> >> > Graag gedaan >> >> > _____________________________ >> >> > Giovanni Santini >> >> > EDS Italy >> >> > ABN-AMRO Working Capital OLS >> >> > Loc: Kostverlorenhof 2 AK8000 >> >> > 1183HE Amstelveen (Amsterdam) >> >> > The Netherlands >> >> > Mobile: +31 (0) 652245333 >> >> > Tel: +31 (0) 203437771 >> >> > Fax: +31 (0) 206299404 >> >> > >> >> > >> >> > -- >> >> > Graag gedaan >> >> > _____________________________ >> >> > Giovanni Santini >> >> > EDS Italy >> >> > ABN-AMRO Working Capital OLS >> >> > Loc: Kostverlorenhof 2 AK8000 >> >> > 1183HE Amstelveen (Amsterdam) >> >> > The Netherlands >> >> > Mobile: +31 (0) 652245333 >> >> > Tel: +31 (0) 203437771 >> >> > Fax: +31 (0) 206299404 >> >> > >> >> > >> >> > >> >> > -- >> >> > Graag gedaan >> >> > _____________________________ >> >> > Giovanni Santini >> >> > EDS Italy >> >> > ABN-AMRO Working Capital OLS >> >> > Loc: Kostverlorenhof 2 AK8000 >> >> > 1183HE Amstelveen (Amsterdam) >> >> > The Netherlands >> >> > Mobile: +31 (0) 652245333 >> >> > Tel: +31 (0) 203437771 >> >> > Fax: +31 (0) 206299404 >> >> > >> >> >> >> >> > >> > >> > -- >> > Graag gedaan >> > _____________________________ >> > Giovanni Santini >> > EDS Italy >> > ABN-AMRO Working Capital OLS >> > Loc: Kostverlorenhof 2 AK8000 >> > 1183HE Amstelveen (Amsterdam) >> > The Netherlands >> > Mobile: +31 (0) 652245333 >> > Tel: +31 (0) 203437771 >> > Fax: +31 (0) 206299404 >> > >> >> >> --------------------------------------------------------------------- >> 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]