J

JSP 잘 아시는분 살려주세요...

· 2013-02-12 (화) 17:44:43 · 1247 · 2

<%
< %@ page contentType="application;" %>
<%@ page import="java.util.*,java.io.*,java.sql.*,java.text.*,java.sql.*"%>

.

.

.

.DB읽는코드

.

.

.

.

String file_path = rs.getString("FILE_STRE_COURS")+rs.getString("STRE_FILE_NM");
String file_name = new String(rs.getString("ORIGNL_FILE_NM").getBytes("euc-kr"),"8859_1");
String filename2 = file_name.substring(file_name.lastIndexOf("/")+1);
File file=new File(file_path);
byte b[]=new byte[(int)file.length()];
 if(file.isFile()){
 response.reset();
 response.setContentType("application/x-msdownload");
 response.setHeader("Content-Disposition","attachment;filename="+filename2+";");
 response.setHeader("Content-Length",String.valueOf(file.length()));
 response.setHeader("Content-Transper-Encoding", "binary");
 response.setContentLength((int)file.length());
   response.setHeader("Pargma", "no-cache");
  response.setHeader("Expires", "-1");
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.close();
fin.close();
}
}

}catch(Exception e){
out.println("rs.next() Error ");
out.println(e.toString());
return;
}
rs.close();
stmt.close();
con.close();

.

.

.

.

.

.
%>

코드는 대략 이런식으로 되있는데 이게 어떤건 다운로드가 정상적으로 실행되고 어떤건 정상적으로 다운로드가 되지않고 400에러가 뜨는 골터지는 문제가 발생합니다...

어딜 어떻게 수정해야하는지 감도 안잡힙니다.. 도와주세요...



|

댓글 2개

2013-02-21 (목) 14:13:38
경로를 확인하세요
이게 파일은 있어요 ㅠㅠ
댓글을 작성하시려면 로그인이 필요합니다.

자유게시판

202,958건
+
제목 글쓴이 날짜 조회
13-02-17 조회 1,197
13-02-16 조회 1,263
13-02-14 조회 1,244
13-02-14 조회 1,201
13-02-14 조회 1,543
13-02-14 조회 1,176
13-02-13 조회 1,324
13-02-12 조회 1,215
13-02-12 조회 1,248
13-02-12 조회 1,264
13-02-11 조회 6,388
13-02-10 조회 1,149
13-02-10 조회 1,184
13-02-09 조회 1,166
13-02-07 조회 1,579
13-02-07 조회 2,009
13-02-07 조회 1,268
13-02-07 조회 1,311
13-02-06 조회 1,225
13-02-06 조회 2,593