response ³»ºÎ °´Ã¼´Â JSP ÆäÀÌÁöÀÇ
ó¸® °á°ú·Î¼ »ç¿ëÀÚ¿¡°Ô º¸³»¾î Áö´Â ÀÀ´äÁ¤º¸¸¦ ³ªÅ¸³À´Ï´Ù.
ÀÌ °´Ã¼´Â
javax.servlet.ServletResponse Interface¸¦ ±¸ÇöÇÏ°í ÀÖ½À´Ï´Ù.
ÇØ´ç °´Ã¼´Â ÄíÅ°°ªÀÇ ¼³Á¤°ú Header Á¤º¸ ( ContentType, Cache ÆÄÀÏ ¼³Á¤ ) µîÀ» ¼³Á¤ÇÒ ¶§ ¸¹ÀÌ »ç¿ëÇÕ´Ï´Ù.
ContentType ¼³Á¤
¾Æ·¡ÀÇ ¿¹Á¦´Â gif
image¸¦ Ãâ·ÂÇÏ´Â jsp script·Î¼ response.setConentType() À» ÀÌ¿ëÇÑ ºÎºÐÀ» º¸½Ã¸é µÉ °Í °°½À´Ï´Ù.
<% try { response.setContentType("image/gif"); ServletOutputStream
sos = response.getOutputStream();
String
filename = "d:\\smson_home\\work\\img_logo.gif"; BufferedOutputStream
bos = null; FileInputStream
fis = new FileInputStream(filename); byte[]
buff = new byte[2048]; bos
= new BufferedOutputStream(sos); for(int
i; ( i = fis.read(buff)) != -1;){ bos.write(buff,0,i); } }
catch(IOException e) { response.setContentType("text/html;charset=euc-kr"); out.println("Error
:" + e.getMessage()); } %> |
Cache ¼³Á¤
À¥ºê¶ó¿ìÀú°¡ ÇØ´ç ÆäÀÌÁö¸¦ ij½¬ÇÏÁö ¸øÇϵµ·Ï response °´Ã¼¸¦ »ç¿ëÇÏ¿© Header¸¦ ¼¼ÆÃÇÏ´Â ºÎºÐÀÔ´Ï´Ù.
<% response.setDateHeader(¡°Expires¡±,0); response.setHeader(¡°Pragma¡±,¡±no-cache¡±); if(request.getProtocol().equals(¡°HTTP/1.1¡±)){ response.setHeader(¡°Cache-Control¡±,¡±no-cache¡±); } %> |
out Object
out object´Â Ãâ·Â¿ë °´Ã¼¶ó°í
»ý°¢ÇÏ¸é µÉ °Í °°½À´Ï´Ù.
<%@ page
contentType="text/html;charset=euc-kr" %> <% out.println(¡°<html><body>Ãâ·Â</body></html>¡±); %> |
- Web Development with Java Server Pages. by
Duane K. Fields & Mark A. Kolb ,°û¿ëÀçÆí¿ª ; InfoBook, Manning