Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

prompt download dialog

Status
Not open for further replies.

kanghao

IS-IT--Management
Jul 4, 2004
68
KR

I want to implement download feature with zip archive file.
but the code below won't work.
Can you help me?

<%@ page import="java.util.zip.ZipOutputStream" %>

<%
ZipOutputStream zos = request.getAttribute("zip_output_stream");
String file_name = (String)request.getAttribute("file_name");
String strClient=request.getHeader("User-Agent");

if(strClient.indexOf("MSIE 5.5") != -1) {
response.setContentType("application");
response.setHeader("Content-Disposition", "attachment;filename=" + file_name + ";");
} else {
response.setContentType("Content-type: application/octet-stream;");
response.setHeader("Content-Disposition", "attachment;filename=" + file_name + ";");
}

if (zos != null){
/*
byte [] b = xml_value.getBytes();
BufferedOutputStream outs = new BufferedOutputStream(response.getOutputStream());
outs.write(b, 0, b.length);
*/
zos.write();
zos.close();
/*
outs.flush();
outs.close();
*/
}
%>
 
You should post this under JSP forum : forum695

Water is not bad as long as it remains outside human body ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top