¸ÞÀÏ ¼ö½Å È®ÀÎ µîÀÇ ¿ëµµ·Î img ÅÂ±× ³»¿¡ ¼ºí¸´ µîÀÇ ÇÁ·Î±×·¥À» È£ÃâÇÏ´Â Äڵ带 ³Ö´Â °æ¿ì°¡ ÀÖ½À´Ï´Ù.
À̶§ ¼ºí¸´¿¡¼´Â 1Çȼ¿Â¥¸® Åõ¸í À̹ÌÁö¸¦ ³»º¸³» »ç¿ëÀÚ°¡ ÀÚ½ÅÀÇ Á¸Àç ¿©ºÎ¸¦ ¾Ë ¼ö ¾ø°ÔÇÕ´Ï´Ù.
(À̹ÌÁö µ¥ÀÌÅÍ°¡ ¿Ã¹Ù¸£Áö ¾Ê°Å³ª Åõ¸íÀ̹ÌÁö°¡ ¾Æ´Ñ °æ¿ì µî¿¡´Â ¸ÞÀÏâÀ̳ª ºê¶ó¿ìÁ® µî¿¡ ¹Ù·Î Ç¥½ÃµÇ´Ï±î¿ä)
ÀÌ·± ·ÎÁ÷À» °¡Áö´Â ÇÁ·Î±×·¥À» ¸¸µé¶§ ¸Å¹ø ¹Ì¸® ¸¸µé¾îµÐ 1Çȼ¿ À̹ÌÁö ÆÄÀÏÀ» Àоî¿Í ±× ÄÁÅÙÃ÷¸¦ º¸³»ÁÖ´Â °Íµµ ¹ø°Å·Ó°Å´Ï¿Í, Çà¿© ³ªÁß¿¡ ±× À̹ÌÁö ÆÄÀÏÀÌ »ç¶óÁö¸é ExceptionÀÌ ¹ß»ýÇÒ °Í ÀÔ´Ï´Ù.
1 Çȼ¿Â¥¸® gif À̹ÌÁöÀÇ Å©±â´Â ¾ó¸¶ Å©Áö ¾ÊÀ¸¹Ç·Î(54¹ÙÀÌÆ®) ´ÙÀ½°ú °°ÀÌ ¾Æ¿¹ »ó¼ö·Î µ¥ÀÌÅ͸¦ ¹Ú¾Æ³õ°í »ç¿ëÇÏ¸é ºÎÇÏÃø¸éÀ̳ª À¯Áö°ü¸® Ãø¸é¿¡¼³ª À¯¸®ÇÒ °Í ÀÔ´Ï´Ù.
// °ø¹é À̹ÌÁö µ¥ÀÌÅÍ (image/gif).
private final static byte[] blankImage =
{
71, 73, 70, 56, 57, 97, 1, 0,
1, 0, -111, -1, 0, -1, -1, -1,
0, 0, 0, -1, -1, -1, 0, 0,
0, 33, -1, 11, 65, 68, 79, 66,
69, 58, 73, 82, 49, 46, 48, 2,
-34, -19, 0, 33, -7, 4, 1, 0,
0, 2, 0, 44, 0, 0, 0, 0,
1, 0, 1, 0, 0, 2, 2, 84,
1, 0, 59
};
private void sendImage(HttpServletResponse response) {
// À̹ÌÁö Àü¼ÛÀ» À§ÇÑ HTTP Çì´õ º¸³»±â
response.setContentType("image/gif");
response.addHeader("Content-Transfer-Encoding", "binary");
response.addHeader("Pragma", "no-cache");
response.setDateHeader("Expires", 1);
response.setContentLength(blankImage.length);
// ½ÇÁ¦ À̹ÌÁö µ¥ÀÌÅÍ º¸³»±â
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
bos = new BufferedOutputStream(response.getOutputStream());
bos.write(blankImage, 0, blankImage.length);
} catch (Exception e) {
e.printStackTrace();
try {
response.sendError(400);
} catch (Exception ex) { }
} finally {
try { if (bos != null) bos.close(); }
catch (Exception ex) { }
} // try catch
} // if
* iWiz´Ô¿¡ ÀÇÇؼ °Ô½Ã¹° À̵¿µÇ¾ú½À´Ï´Ù (2010-02-03 16:57) |
|