01: package com.bostechcorp.cbesb.console.server;
02:
03: import java.io.File;
04: import java.io.IOException;
05:
06: import javax.servlet.ServletException;
07: import javax.servlet.http.HttpServlet;
08: import javax.servlet.http.HttpServletRequest;
09: import javax.servlet.http.HttpServletResponse;
10:
11: import com.bostechcorp.cbesb.common.util.EsbPathHelper;
12:
13: public class LogDownLoadServlet extends HttpServlet {
14:
15: private static final long serialVersionUID = 1090544931451083174L;
16:
17: @Override
18: protected void doGet(HttpServletRequest request,
19: HttpServletResponse response) throws ServletException,
20: IOException {
21:
22: String name = request.getParameter("name");
23:
24: response.setContentType("APPLICATION/OCTET-STREAM");
25: response.addHeader("Content-Disposition",
26: "attachment;filename=\"" + name + "\"");
27: try {
28: String path = EsbPathHelper.getCbesbHomeDir();
29: String filePath = path + File.separator + "log"
30: + File.separator + name;
31:
32: java.io.OutputStream os = response.getOutputStream();
33: java.io.FileInputStream fis = new java.io.FileInputStream(
34: filePath);
35:
36: byte[] b = new byte[1024];
37: int i = 0;
38:
39: while ((i = fis.read(b)) > 0) {
40: os.write(b, 0, i);
41: }
42:
43: fis.close();
44: os.flush();
45: os.close();
46: } catch (Exception e) {
47: }
48: }
49: }
|