File Download (two streams at both ends) and file download (two streams)

Source: Internet
Author: User

File Download (two streams at both ends) and file download (two streams)
1.1 download the server-side Write Program (two streams at both ends)

The header that must be set during download: content-Type Content-Disposition

Response. setContentType (getServletContext (). getMimeType (filename ));

Response. setHeader ("Content-Disposition", "attachment; filename =" + filename );

 

 

1.2. traverse all files in the directory for download

 

The linked list is used for query)

Jsp page code implementation:

 

 

Server Download and browser Encoding Problems:

 

 

1.3. Precautions for file download:

Two streams: the input stream that reads the files to be downloaded. Output stream, send data to the client

2 Head: Set the Data Type of the downloaded file. Tell the browser to process the response data in download Mode

Different browsers need to encode the downloaded file name.

 

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.