js| Download
Last night to download the file with Jspsmartupload, wrote a download page (download.jsp) as follows:
<%@ page contenttype= "text/html;charset=gb2312"%>
<%@ page import= "java.io.*,mail.util.encoding"%>
<jsp:usebean id= "mysmartupload" scope= "page" class= "Com.jspsmart.upload.SmartUpload"/>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<body>
<%
String filename =encoding.encodingunicode (request.getparameter ("filename"));
Mail. Dbbase Dbbase=mail. Dbbase.getinstance ();
String Path=dbbase.getpath ();
Class
Mysmartupload.initialize (PageContext);
Set contentdisposition NULL to prevent the browser from automatically opening the file.
Ensure that you click on the link to download the file. If not set, the downloaded file name extension is
Doc, the browser will automatically open it in Word. When the extension is PDF,
The browser will be opened with Acrobat.
Mysmartupload.setcontentdisposition (NULL);
Download files
if (filename!=null) {
Mysmartupload.downloadfile (Path+filename);
}
%>
</body>
When the download is performed, the file is downloaded correctly, but it always complains.
Java.lang.IllegalStateException:getOutputStream () has already been called for this response
Later found that the implementation of the downloaded page, outside the scope of the Java script (that is, outside the <% ...%>), do not include HTML code, space, carriage return or newline characters, and some words will not download correctly. If not, you can add a line break between%><% in the above source code, and then download it to ensure error. Because it affects the data stream returned to the browser, it causes parsing errors.
Fix the problem after modification.