JSP implementation file download code (1/4)

Source: Internet
Author: User
Tags zip

JSP Tutorial implementation file download code
/*
1. Support for single file downloads. Supports multiple file zip compression downloads. Multi-File Zip compression allows you to keep or delete replicas on the server. Supports the download of a specific string or byte array with the specified filename.
2. You need to provide response objects during the download process. and choose the Download form.
3. Check before downloading the process to avoid any errors.
4. Error messages are reported when an error occurs during the download process.
5. Japanese system under the file name is Chinese when garbled problem.
6. A relatively cumbersome setting is required before processing.

Set the response object that the implementation download must be.
public void Setresponse (httpservletresponse response)
Set Download mode: 0 for ordinary single file download. 1 for multiple files compressed into a zip package download. 2 for the specified string, such as stitching into the file content provided to the user to download.
public void Setdowntype (int fileType)
Sets the name of the file to display when downloading.
public void Setdisfilename (String fileName)

Set compressed file for temporary save path (path is absolute path) when compressing file download
public void Setzipfilepath (String path)

When compressing file downloads, set whether the server-side generated compressed files are deleted. True Delete; false retention.
public void Setzipdelflag (Boolean b)

When compressing file downloads, set the file path of the file to compress (the path is absolute)
public void Setzipfilenames (string[] fileNames)
When downloading a single file, set the path of the download file (absolute path)
public void Setdownfilename (String fileName)

When the string is generated to simulate downloading, the contents of the file are set. parameter is a string (can be invoked multiple times)
public int setfilecontent (String filecontent)

When the string is generated to simulate downloading, the contents of the file are set. parameter is a byte array (can be invoked multiple times)
Return value: 0 operation is normal; 9 io exception occurred.
public int setfilecontent (byte[] filecontent)

Call this method to end the file content setting when you simulate a download of a string generated file content.
Return value: 0 operation is normal; 9 io exception occurred.
public int Setfilecontentend ()

The main processing function.
Return value: 0 normal processing; 1 response object not set.  2 The file download mode is not set.  3 The file name to display is not set.  4 the file path to download is not set, or the downloaded file path is not present. 9 IO exception.
public int process ()

Home 1 2 3 4 last page
Related Article

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.