Content-disposition response Header

Source: Internet
Author: User
Tags rfc

The Content-disposition property is used as an identification field for the download file in the rfc2616 http://www.rfc-editor.org/rfc/rfc2616.pdf Chapter 19.5 Additional In Features

Have introduction, specific introduction please see Http://www.rfc-editor.org/rfc/rfc1806.txt

The fields are described below:

Disposition: = "Content-disposition" ":"  
               disposition-type  
               * (";" Disposition-parm)  
disposition-type: = " inline "  
                  /" attachment "  
                  /Extension-token  
                  ; values are not case-sensitive  
disposition-parm: = Filename-parm/parameter  
filename-parm: = "filename" "=" value;  

There are two types of content-disposition properties: inline and Attachment inline: Display the contents of the file directly in the page attachment: Pop-up dialog lets users download specific examples:

Content-type:image/jpeg  
content-disposition:inline;filename=hello.jpg  
content-description:just a small Picture of Me  

To open code within a page:

File File = new file ("Rfc1806.txt");  
String filename = File.getname ();  
Response.setheader ("Content-type", "Text/plain");  
Response.AddHeader ("Content-disposition", "inline;filename=" + New String (Filename.getbytes (), "Utf-8"));  
Response.AddHeader ("Content-length", "" "+ File.length ());  

Pop-up Save box Code:

File File = new file ("Rfc1806.txt");  
String filename = File.getname ();  
Response.setheader ("Content-type", "Text/plain");  
Response.AddHeader ("Content-disposition", "attachment;filename=" + New String (Filename.getbytes (), "Utf-8"));  
Response.AddHeader ("Content-length", "" "+ File.length ());  

=====================================================

Turn from: http://blog.csdn.net/androidmi/article/details/7519243

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.