Jsp used for direct download files function
Abstract: The realization of direct download files jsp function
</ Td> </ tr> <tr> <td width="552" height="35" valign="top" class="ArticleTeitle"> <%
/ / Sometimes a user wants to download files, but this type of file in the system associated with the browser, the results will become open in IE.
/ / A common word, excel, such as pdf. Therefore the documents translated into data flow to its browser does not know the type of document to download purposes.
/ / Usage:
/ / Download image
String root = getServletContext (). GetRealPath ("/");
String path = request.getParameter ( "path");
String name = request.getParameter ( "name");
Response.setContentType ( "unknown");
Response.addHeader ( "Content-Disposition", "filename = \" "+ name +" \ "");
Try
(
Java.io.OutputStream os = response.getOutputStream ();
Java.io.FileInputStream fis = new java.io.FileInputStream (root path + + name);
Byte [] b = new byte [1024];
Int i = 0;
While ((i = fis.read (b))> 0)
(
Os.write (b, 0, i);
)
Fis.close ();
Os.flush ();
Os.close ();
)
Catch (Exception e)
(
)
%> </ Td> <td width="175" valign="top" class="ArticleTeitle">
</ Td> </ tr> <tr> <td height="25" colspan="2" valign="top" class="ArticleTeitle">
↑ Back
Tags: function, java download







rycidy…
Claudine Barreto Wedding …
lovoruw…
sears scratch and dent delaware …