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.

7 comments:

  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

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

    ReplyDelete
  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

    ReplyDelete
  4. Regardless of to what extent you take to pay it back, it will never cost you more than $10,000. The rebate rate offered relies upon various things, incorporating time in business, FICO assessment, process history, and so on. Cash Advances San diego

    ReplyDelete