Archive for the 'servlet' Category

Filename in response

folder

I was writing a servlet whose response is PDF, CSV, XLS etc. This works fine, but when I tried to save it HDD the url is given as the filename. I was wondering how to explicitly specify the filename. Here is the solution.

response.setHeader("Content-Disposition", "inline; filename=xyz.pdf" );

When we set this header property in the response, The filename will be xyz.pdf. Nice na!

https - Servlet - Attachment - IE not working

Hi, I have a servlet which will send me PDF stream. It is working good in IE and Firefox. When operating in secured mode (https), IE couldnt download the attachment. it stops in halfway. There were no exceptions thrown at the servlet end. Atlast, we found the line

response.setHeader(”Pragma”, “no-cache”);

is the culprit. when we dint set this header param when operating in secured mode,
it is working fine. :)

Microsoft site says “This behavior occurs when the Content Expiration option in the
Hypertext Transfer Protocol (HTTP) Headers, within IIS, is set to
Expire Immediately. Internet Explorer must save any Microsoft Office
file to the local cache directory, and then use the associated
application to open the file. If you set Content Expiration to Expire
Immediately, the Office documents are not cached locally and the
operation fails.”

mm. anyway, it dint take much time. we cud guess this from another servlet we have :)

Chris Holland: The Blog.: ServletRequest.getParameter and UTF-8

Chris Holland: The Blog.: ServletRequest.getParameter and UTF-8

Next Page »