Data AccessCore JavaApp FrameworksViewTestingBuildingDeploymentDev ToolsSecurityOpinions

Thursday, September 24, 2009

How to Post a SaveAs Dialog

To prompt a 'Save As' dialog box when downloading a file, set the Content-Disposition to 'attachment' in the HTTP header.

Read RFC 2183

You can also pre-set the saved filename by setting the filename parameter as well.

Be sure to set the appropriate MIME type or content type as well.

Below is a code example of how this would be achieved in a java servlet before committing the response.

response.setContentType( "application/pdf" );
response.setHeader("Content-disposition","attachment; filename=" + "Example.pdf" );

Hope this helps, if it does, help me out by clicking on one of my sponsors.


  1. I have read your blog its very attractive and impressive. I like it your blog.

    Java Training in Chennai Java Training in Chennai | Core Java Training in Chennai

    Online Java Training Java Online Training | Java J2EE Online Training | JavaEE Training Institute in Chennai

  2. Hi, Thanks for sharing this infomation, If you are looking for a packers and movers in Ernakulam
    so you can visit us

  3. The teddy bear, a stuffed plush toy, is among the most popular toys in the U.S. The toy is so popular that September 9 is designated as Teddy Bear Day. Over the years, children and adults have come to treasure teddy bears for many reasons. adorable teddy bear names