Reputation: 23
Our Application is build on Spring framework and it is hosted on WAS 6.1. It was designed for the Internet Explorer 6 (as the users using IE 6). It is opening a pdf file through AJAX communication through the controller. In the background it calls a mq to fetch the byte[]. It is written in the bufferedOutputStream of the response.
It is working fine in development and testing environment but in production environment it is not working fine always. It is opening sometimes, sometimes it is not. (For load balancing we have more than 1 servers.)
Sometimes the request query string is set in the filename and while trying to save the attachment it is giving the following error message in the pop up:
"Internet cannot download ......url from abc.com The file could not be written in the cache"
PFB the code:
byte[] letterByteArr = null;
letterByteArr = fetchFromMQ();
bufferedOutputStream = new BufferedOutputStream(response.getOutputStream());
response.reset();
response.setContentType(application/pdf);
response.setHeader(Content-disposition, attachment; filename=LP.pdf);
int length = letterByteArr.length;
response.setContentLength(length);
bufferedOutputStream.write(letterByteArr, 0, length);
bufferedOutputStream.flush();
The similar piece of code is running fine in another application which is running in different jvm.
Could anyone suggest the possible solutions for this problem if they faced during your code implementation? Where could be the possible problem in WAS, network, IE or Abode?
Upvotes: 1
Views: 2162
Reputation: 1
I am facing the same problem and I added the reponse headers to solve this problem.
But I had to remove the response.reset();
; only after that the downloading problem is not occuring.
I don't know the reason behind this but it's working.
The issue only is that the data of the excel is different to the data in pdf fiel in my application.
Upvotes: 0
Reputation: 1108712
This sounds much like http://support.microsoft.com/kb/812935. The problem is, IE6 won't download the PDF file when it is served over HTTPS instead of HTTP while the Cache-Control
and/or Pragma
headers are set to no-cache
.
Add the following response headers:
response.setHeader("Cache-Control", "public");
response.setHeader("Pragma", "public");
Upvotes: 1