loadAdobeReader.jsp
3.21 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="weaver.general.Util"%>
<%@ page import="java.io.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
String begload=Util.null2String(request.getParameter("begload"));
if("true".equals(begload)){
String fontFileName = "AdobeReader.rar";
String fontFilePath = "/workflow/exceldesign/";
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
String projectPath = this.getServletConfig().getServletContext().getRealPath("/");
if (projectPath.lastIndexOf("/") != (projectPath.length() - 1) && projectPath.lastIndexOf("\\") != (projectPath.length() - 1)) {
projectPath += "/";
}
String filepath = projectPath + fontFilePath + fontFileName;
response.reset();
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
response.setContentType("application/octet-stream;charset=UTF-8");
response.setHeader("Content-disposition", "attachment;filename=\"" + fontFileName + "\"");
bis = new BufferedInputStream(new FileInputStream(filepath));
bos = new BufferedOutputStream(response.getOutputStream());
byte[] buff = new byte[2048];
int bytesRead;
while ((bytesRead = bis.read(buff, 0, buff.length)) != -1) {
bos.write(buff, 0, bytesRead);
}
bos.flush();
//out.clear();
out = pageContext.pushBody();
} catch(IOException e) {
e.printStackTrace();
} finally {
if (bis != null) {
try {
bis.close();
bis = null;
} catch (IOException e) {
}
}
if (bos != null) {
try {
bos.close();
bos = null;
} catch (IOException e) {
}
}
}
return;
}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Load Adobe Reader</title>
<style type="text/css">
.loadDiv{height:188px; width:521px; margin:122px auto 0px auto; border:#dbdbdb solid 1px;}
.left{width:175px; height:100%; float:left;}
.left span{margin-left:60px; font-size:14px; color:#134070; }
.left .img{width:100%; height:100px; padding-top:38px; background: url("/workflow/exceldesign/image/printpdf_wev8.png") no-repeat 38px 38px; }
.right{width:346px; height:100%; float:left;}
.right .right_top{margin-top:66px; }
.right .right_top span{padding-left:4px; font-size:14px;color:#242424}
.right .right_bottom{margin-top:42px; margin-left:94px}
.right .right_bottom a{color:#42b6f8; font-size:16px;}
</style>
</head>
<body>
<div class="loadDiv">
<div class="left">
<div class="img"></div>
<span>打印提示</span>
</div>
<div class="right">
<div class="right_top">
<span>请先安装 Adobe Reader 才能正常打印文件</span>
</div>
<div class="right_bottom">
<a href="/workflow/exceldesign/loadAdobeReader.jsp?begload=true">立即下载</a>
</div>
</div>
</div>
</body>
</html>