Lessons learned using JSPSMARTupload download

xiaoxiao2021-03-06  46

Download file with JSPSmartupload last night, write a download page (Download.jsp) as follows:

<% @ Page ContentType = "text / html; charset = GB2312"%>

<% @ page import = "java.io. *, mail.util.encoding"%>

<%

String filename = encoding.encodingunicate (Request.GetParameter ("filename"));

Mail.dbbase dbase = mail.dbbase.getinstance ();

String path = dbbase.getpath ();

// Initialization

MySmartupload.initialize (PageContext);

// Set contentdisposition to NULL to prohibit the browser automatically open the file,

/ / Ensure that the click link is the download file. If it is not set, the downloaded file extension is called

// DOC, the browser will automatically open it with Word. When the extension is PDF,

// The browser will open with Acrobat.

MySmartupload.setContentDisPosition (NULL);

// download file

IF (filename! = NULL) {

Mysmartupload.downloadfile (Path FileName);

}

%>

When performing download, the file can be downloaded correctly, but it always reports wrong.

Java.lang.illegalStateException: getOutputStream () HAS Already Been Called for this Response

Later, I found out that the downloaded page is executed, outside the Java script (ie <% ...%>), do not include characters such as HTML code, space, carriage return, and wrap, and some will not download it correctly. If you don't believe it, you can add a newline character in the above source code, and then download it, and ensure an error. Because it affects the data stream returned to the browser, it causes the parsing error.

After the changes are resolved.

转载请注明原文地址:https://www.9cbs.com/read-63182.html

New Post(0)