블로그 이미지
헤이장

Notice

Recent Post

Recent Comment

Recent Trackback

calendar

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
  • total
  • today
  • yesterday
2009. 7. 27. 13:22 Web/Jsp

 DownJar.java

// import 생략

public class DownJar extends HttpServlet { 

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
                                                                        throws ServletException, IOException {
        resp.setContentType("application/jar");
        ServletContext ctx = getServletContext();
        InputStream is = ctx.getResourceAsStream("/dwr.jar");
        int read = 0;
        byte[] bytes = new byte[1024];

        OutputStream os = resp.getOutputStream();
        while ((read = is.read(bytes)) != -1) {
            os.write(bytes, 0, read);
        }
        os.flush();
        os.close();
    }
}


경로에 있는 파일을 읽어 출력 스트림에 기록한다

posted by 헤이장