<%@ page contentType="text/html;charset=KSC5601" %> <%@ taglib uri="/tags/struts-bean" prefix="bean" %> <%@ taglib uri="/tags/struts-html" prefix="html" %> <%@ taglib uri="/tags/struts-logic" prefix="logic" %> <%@ page import="kr.co.amail.ems.init.Param" %> <%@ page import="java.util.*,java.io.*,java.text.*" %> <%@ page pageEncoding="EUC-KR"%> <% String resultExcelFile; String path = Param.get("upload.store") + "/logResult/"; String toFile = (String)request.getAttribute("toFile"); resultExcelFile = path + toFile; String gubun = (String)request.getAttribute("gubun"); System.out.println(gubun); System.out.println(toFile); if(toFile.length() > 0){ File file = new File(resultExcelFile); // Àý´ë°æ·ÎÀÔ´Ï´Ù. byte b[] = new byte[4096]; String strClient=request.getHeader("User-Agent"); response.reset(); response.setContentType("application/octet-stream"); if(gubun.equals("excel")){ response.setHeader("Content-Disposition", "attachment;filename=" + "AnalysisResult.xls" + ";"); } else if(gubun.equals("userUnknown")){ response.setHeader("Content-Disposition", "attachment;filename=" + "UserUnknownResult.txt" + ";"); } response.setHeader("Content-Type", "application/x-msdownload"); if (file.isFile()) { BufferedInputStream fin = new BufferedInputStream(new FileInputStream(file)); BufferedOutputStream outs = new BufferedOutputStream(response.getOutputStream()); int read = 0; try { while ((read = fin.read(b)) != -1){ outs.write(b,0,read); } outs.close(); fin.close(); } catch (Exception e) { System.out.println(e.getMessage()); } finally { if(outs!=null) outs.close(); if(fin!=null) fin.close(); } } } %> test