The download feature in the JSP page is taken from: http://www.cnjsp.org/view.jsp? Column = 2 & id = 93 If it is just in a file, you can use the super-connected to get it, but use the super chain Safety, no one can access, using the program is of course good, but download the file of the directory that the Web can be downloaded to the certified visitor. I have written an example of picking the picture from the database to push to the page. You just need to The data source of the database is changed from a data source read from a file, and then change the document header "image / gif" to "Application / X-msdownLoad" can output a file to the browser. File T_file = New Java.io.file (sourcefilepathname); long l = t_file.length (); // file length InputStream in = new fileinputstream (t_file); if (in! = null) {string fs = t_file.getname (); response. RESET (); resplication.setContentType ("Application / X-msdownLoad"); // string s = "attachment; filename =" fs; //response.setheader ("content-disposition ", s); // Output File metadet information response.setContentLength (INT) L); // Setting the input file length Byte [] b = new byte [2048]; int LEN = 0; while ({len = in.read (b))> 0) {Response.getOutputStream (). Write (b, 0, len); // Output to the browser} in.close (); // Close file input stream} finishing publishes: solo match Umbrella
Article reply:
Re: Download features in the JSP page
Author: aaaaaaa Posted: 2004-09-16 15:42
While ({len = in.read (b))> 0);
{
Response.getOutputStream (). Write (b, 0, len); // Output to the browser /
}
mistaken. . .
Re: Download features in the JSP page
Author: kid Posted: 2004-05-12 03:22
ContentType: "Application / VND.MS-Excel"
Re: Download features in the JSP page
Author: kid Posted: 2004-05-12 03:21
TO: Yu Zhi Shu "<% @ Page ContentType =" Application / VND.ms-Excel "%>" or "<% response.setContentType (" Application / VND.MS-Excel ")%>"
Re: Download features in the JSP page
Author: kid Posted: 2004-05-12 03:02
TO: Yu Zhishu <% page contenttype = "Application / VND.MS-Excel"%> or <% response.setContentType ("Application / VND.MS-Excel");%>
Re: Download features in the JSP page
Author: Stephen was published on: 2004-02-21 00:21
Contact the author via Email