일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Google Map
- appspresso
- PLSQL
- Struts
- tomcat
- dock
- Android
- phonegap
- jQuery
- oracle
- rowspan
- 전자정부프레임워크
- JDOM
- 가우스
- ibsheet
- jsr 296
- sencha touch
- swingx
- MFC
- MySQL
- iBATIS
- Ajax
- JSON
- WebLogic
- PHP
- GPS
- Eclipse
- 선택적조인
- node.js
- Spring
- Today
- Total
Where The Streets Have No Name
jsp 다운로드 이렇게 하면 됩니다. ( 한글도 됩니다. ) 본문
<%@ page contentType="text/html; charset=8859_1"import="java.io.*" errorPage = "/error/error.jsp" %><%
String clips = new String((request.getParameter("clips")).getBytes("8859_1"),"EUC_KR");
String filename = clips; //파일 이름을 받는다.
String path = getServletContext().getRealPath("/");
String other_path="upload/";
File file = new File(path+other_path+"/"+filename); // 절대경로입니다.
response.setContentType("application/octet-stream");
String Agent=request.getHeader("USER-AGENT");
//response.setContentType("application/unknown"); //화일형태
if(Agent.indexOf("MSIE")>=0){
int i=Agent.indexOf('M',2);//두번째 'M'자가 있는 위치
String IEV=Agent.substring(i+5,i+8);
if(IEV.equalsIgnoreCase("5.5")){
response.setHeader("Content-Disposition", "filename="+new String(filename.getBytes("euc-kr"),"8859_1"));
}else{
response.setHeader("Content-Disposition", "attachment;filename="+new String(filename.getBytes("euc-kr"),"8859_1"));
}
}else{
response.setHeader("Content-Disposition", "attachment;filename="+new String(filename.getBytes("euc-kr"),"8859_1"));
}
byte b[] = new byte[5 * 1024 * 1024]; //5M byte까지 업로드가 가능하므로 크기를 이렇게 잡아주었음.
if (file.isFile()){
try {
BufferedInputStream fin = new BufferedInputStream(new FileInputStream(file));
BufferedOutputStream outs = new BufferedOutputStream(response.getOutputStream());
int read = 0;
while ((read = fin.read(b)) != -1){
outs.write(b,0,read);
}
outs.flush();
outs.close();
fin.close();
}catch(Exception e){}
}
%>