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!

Advertisements

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 🙂

JSP, Filter and Forward

Filters generally applied to corresponding requests. But when the request is forwarded from one servlet to another source, that will not be processed with Filter. (I checked with Tomcat 4.1). We need to add some more parameters with Filter mapping as noted below.

<filter-mapping> <filter-name>VJFilterTest</filter-name> <!–<servlet-name>VJServlet</servlet-name>–> <url-pattern>/servlet/MyTest</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping> ————————————————— *Free* software is a matter of liberty not price. You should think of “free” as in “free speech”.