|
Juergen,
Thanks. It works perfectly for my scenario (setting cache seconds zero prevents caching for Jasper Reports). I have couple of naive questions. Is the issue # Now AbstractExcelView, AbstractPdfView as well as AbstractJasperReportsView returns true for generatesBinaryContent and prepareResponse method handle this value appropriately. Previously AbstractJasperReportsView do this by a response.reset(), which is not needed now. I can't find looking at the 2.5 version code, what was the previous workaround for AbstractExcelView and AbstractPdfView? Thanks. Shahid That forum thread might indeed be related. Pre 2.5.2, we didn't have a built-in workaround for AbstractExcelView and AbstractPdfView at all... So people had to care for those headers - or the resetting of those headers - in their custom subclasses. This should hopefully be resolved with a consistent solution for all those views now.
Juergen Then the problem of downloading binary files i.e. an error message in IE ("C:\Temp\Temporary Internet Files\Content.IE5\S1244HKJD\sheet[1].xls chould not be found. check the spelling of the file name and verify that the file location is correct.") shouldn't appear. The caching problem is resolved for the HTML view using cacheSeconds 0, but I still got the error message downloading the PDF or Excel version of the report using the same view.
So with no cacheSeconds property specified, displaying basically works for any kind of view, with HTTP and HTTPs - except that it's not preventing caching?
With cacheSeconds=0, it works for HTML views but not for PDF/Excel views? Does this apply to HTTPS only or to HTTP as well? I assume for HTTPS only, in which case this would indicate that well-known IE bug? I could imagine that the "Expires" header still triggers undesirable IE behavior here. Does it make a difference if you specify useExpiresHeader=false next to your cacheSeconds setting? Juergen Hi,
Finally I got time to throughly test this. I have tested both with spring 2.5 stable release and the latest nightly build. I attached the test result. Let me know, it its not explanatory to you. Now the only problem seems with PDF files and for HTTP requests. Shahid Test result for latest nightly build and 2.5 stable release.
Thanks for the tests! It seems like the special "private" headers that allow for temporary storage on the clients need to be set independent from HTTP/HTTPS mode then. I've revised our code to *always* send those headers for download views now, not just for HTTPS requests.
This should be available in tonight's snapshot (-392 or above). Please give it a try, in particular with PDF/Excel files served by plain HTTP requests... Juergen Hi, now its working fine and no need to set up cacheSeconds to -1 for binary files. Thanks for the short but useful fix.
BTW, I couldn't run with the latest nightly build, got an exception like the following: java.lang.IllegalStateException: ApplicationObjectSupport instance [org.springframework.web.servlet.view.InternalResourceView: unnamed; URL [/fpage/dashboar d]] does not run in an ApplicationContext at org.springframework.context.support.ApplicationObjectSupport.getApplicationContext(ApplicationObjectSupport.java:125) at org.springframework.web.context.support.WebApplicationObjectSupport.getWebApplicationContext(WebApplicationObjectSupport.java:70) at org.springframework.web.context.support.WebApplicationObjectSupport.getServletContext(WebApplicationObjectSupport.java:87) at org.springframework.web.servlet.view.InternalResourceView.exposeForwardRequestAttributes(InternalResourceView.java:292) at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:186) at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:252) ................................................................................................ ................................................................................................ Its working for the new fix for GlassFish as described in the change log - "InternalResourceView only exposes forward attributes when running on Servlet <2.5 (for GlassFish compatibility)". Later I commented out the line 275, 276 and 278 of InternalResourceView to do my test. Shahid Thanks for the feedback! Indeed, InternalResourceView should keep working with direct instantiation as well, i.e. not rely on the the availability of a ServletContext (since all it really does there is a version number check). I've fixed this for the next 2.5.2 snapshot.
Juergen |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
I've added a "prepareResponse"/"generatesBinaryContent" method pair to AbstractView, implementing the HTTPS cache header workaround in a generic fashion if the view class indicates that it generates binary content. What we do there now - only in case of an actual HTTPS request - is setting "Pragma: private" and "Cache-Control: private, must-revalidate", which seems to be the common solution for this IE problem. This means that any cache headers - whether set by Spring configuration or set by Tomcat - will be overridden for views that explicitly indicate binary content (in particular for PDF and Excel documents).
AbstractPdfView and Abstract(J)ExcelView simply participate in AbstractView's HTTPS cache header workaround for IE now, and so does AbstractJasperReportsView instead of its hard response reset. So you should be able to specify custom cache settings now for HTTP requests that generate documents, except for HTTPS requests where only the "Expires" header will be taken from your custom configuration - "Pragma" and "Cache-Control" will always be set to "private" for such a request (which makes sense in general, not just as an IE workaround; otherwise you may override the View's "prepareResponse" method accordingly).
This will be available in tonight's 2.5.2 snapshot (-385 or above; available from http://static.springframework.org/downloads/nightly/snapshot-download.php?project=SPR). Please give it a try and let me know whether it works for you!
Juergen