sitelink1 | |
---|---|
sitelink2 | |
sitelink3 | |
sitelink4 | |
sitelink5 | |
sitelink6 |
샘플 다운로드 -> 91975.7z
[[CODE]]
<%@ page import="java.io.File" %>
<%@ page import="java.io.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>파일 다운로드 테스트</title>
</head>
<body>
<%
String fileName = request.getParameter("fileName");
fileName = "/TOPS_RP/91975/ExcelExport_Sample.xlsx";
ServletContext context = getServletContext();
String realFolder = context.getRealPath("/");
String filePath = realFolder + "\\" + fileName;
out.println("filePath="+filePath);
try{
out.clear();
out = pageContext.pushBody();
File file = new File(filePath);
byte b[] = new byte[4096];
response.reset();
response.setContentType("application/octet-stream");
String Encoding = new String(fileName.getBytes("UTF-8"), "8859_1");
response.setHeader("Content-Disposition", "attatchment; filename = " + Encoding);
FileInputStream is = new FileInputStream(filePath);
ServletOutputStream sos = response.getOutputStream();
int numRead;
while((numRead = is.read(b,0,b.length)) != -1){
sos.write(b,0,numRead);
}
sos.flush();
sos.close();
is.close();
}catch(Exception e){
e.printStackTrace();
}
%>
</body>
</html>