StyleDownload.jsp
1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ include file="/page/maint/common/initNoCache.jsp" %>
<%@ page import="weaver.general.*" %>
<%@ page import="org.apache.commons.fileupload.*" %>
<%@ page import="java.util.zip.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.Date" %>
<%@page import="weaver.page.maint.layout.PageLayoutUtil"%>
<%@page import="weaver.homepage.cominfo.HomepageBaseLayoutCominfo"%>
<%@page import="org.apache.commons.io.FileUtils"%>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="pc" class="weaver.page.PageCominfo" scope="page" />
<jsp:useBean id="baseBean" class="weaver.general.BaseBean" scope="page"/>
<%
String tempPath = GCONST.getRootPath();
String type = Util.null2String(request.getParameter("type"));
String styleid = Util.null2String(request.getParameter("styleid"));
if("menuh".equals(type)){
tempPath += pc.getConfig().getString("menuh.conf");
}else if("menuv".equals(type)){
tempPath += pc.getConfig().getString("menuv.conf");
}else{
tempPath += pc.getConfig().getString("style.conf");
}
response.setContentType("application/x-msdownload");
response.setHeader("Content-disposition", "attachment;filename="+styleid+".xml");
File file = new File(tempPath+styleid+".xml");
baseBean.writeLog(file.getAbsolutePath());
FileInputStream fis = null;
OutputStream os = null;
out.clearBuffer();
byte[] bos = new byte[1024];
int length = 0;
try {
fis = new FileInputStream(file);
os = response.getOutputStream();
while((length=fis.read(bos))!=-1){
os.write(bos, 0, length);
// os.flush();
}
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
if(os!=null)
os.close();
if(fis!=null)
fis.close();
} catch (Exception e) {
e.printStackTrace();
}
}
%>