<?xml version="1.0" encoding="euc-kr" ?>
<?xml-stylesheet type="text/xsl" href="../okjsplec_c.xsl" ?>
<lecture>
	<title>JSP·Î ÀÌ¹ÌÁö »ý¼ºÇÏ±â</title>
	<who>kenu</who>
	<when>2001-09-11 5:51¿ÀÀü</when>
	<what>
		<text>
		¾ÖÇÃ¸´À¸·Î´Â ±×¸²À» ±×·Á¼­ À¥ºê¶ó¿ìÀú¿¡¼­ º¼ ¼ö ÀÖ¾ú½À´Ï´Ù. ±×·³ JSP ·Î ±×¸²À» ±×¸± ¼ö ÀÖÀ»±î¿ä? Á¤´äÀº YES ÀÔ´Ï´Ù. ÇÏÁö¸¸ Áö±Ý±îÁö´Â No ¿´½À´Ï´Ù. ¾Æ¹«µµ °¡¸£ÃÄÁÖ´Â »ç¶÷ÀÌ ¾ø¾î¿ä. ¾û¾û~ ³ª ¾î¶»ÇØ È¸»ç ÂÑ°Ü³ª¸é... ¿ì¸® ¾ÆÀÌ ¸ÔÀ» °Í ÀÔÀ» °Í »ç·Á¸é ¾Æ³»°¡ ¹ö´Â µ·¸¸À¸·Î´Â ºÎÁ·ÇÑµ¥... ´ÙÇàÈ÷ ¸ðÀ¯ ¸ÔÀ¸´Ï±î ¿ìÀ¯°ªÀº ¾Èµå´Âµ¥, Á¾ÀÌ ±âÀú±Í´Â ¾î¶»ÇÏ¶ó±¸... &lt;-- ¾îÁ¦±îÁö ÀúÀÇ ¸ð½ÀÀÌ¾ú½À´Ï´Ù.
		</text>
		<image>/images/spacer.gif
		</image>
	</what>
	<what>
		<text>
		ÇÏÇÏ, ²¨¶±¾ø½¿´Ù. °ÅÀú ¿ºº¯¿¡¼­´Â JSP ·Î ±×¸²±×¸®´Â °ÍÀº jsp Ãà¿¡µµ ¸ø³§´Ï´Ù. ÇìÇì ³ó´ã ±×¸¸ÇÏ°í, ^^ ¼Ò½º °ø°³ÇÕ´Ï´Ù. ¾Æ´Ï, ¹æ¹ýÀ» °ø°³ÇÕ´Ï´Ù.
		</text>
		<image>/images/spacer.gif
		</image>
	</what>
	<what>
		<text>
		ÁÖ½ÄÇöÈ² ±×·¡ÇÁ³ª, ¹æ¹®Åë°è±×·¡ÇÁ µîÀ» ±×¸± ¼ö ÀÖ½À´Ï´Ù. ÇÑ°¡Áö ±â¾ïÇØ¾ß ÇÒ °ÍÀº °ø°³ÇÁ·Î±×·¥À» ³»³õ°í ¸¹Àº »ç¶÷µéÀÇ ¼ö°í¸¦ ´ú¾îÁÖ´Â ¶óÀÌºê·¯¸® °³¹ßÀÚµé¿¡°Ô °¨»çÇØ¾ß ÇÑ´Ù´Â °ÍÀÔ´Ï´Ù. java ·Î °ø°³µÈ ¶óÀÌºê·¯¸® Áß¿¡ www.acme.com ¿¡¼­ ³ª¿Â GifEncoder °¡ °¡Àå À¯¸íÇÕ´Ï´Ù. ÀÌ ¹Û¿¡µµ jclassµµ ÀÖ°í, Àúµµ ¾ËÁö ¸øÇÏ´Â ¿©·¯ °ø°³µÈ ¼Ò½º°¡ ÀÖÀ» °Ì´Ï´Ù. ÀÏ¹ÝÀûÀ¸·Î ¸¹ÀÌ ¾²ÀÌ´Â www.acme.com ÆÐÅ°Áö¸¦ »ç¿ëÇÏµµ·Ï ÇÏ°Ú½À´Ï´Ù.
		</text>
		<image>/images/spacer.gif
		</image>
	</what>
	<what>
		<text>
		test È¯°æÀº Tomcat 3.2.3 °ú windows 2000 professional , ±×¸®°í apache 1.3.20 ÀÔ´Ï´Ù. ¾Æ! jdk´Â 1.3.1_02 ÀÔ´Ï´Ù. ¹öÀüÀÌ ´Þ¶ó¼­ ¾ÈµÇ´Â °æ¿ì´Â... À¸¾Ç~ »ì·ÁÁÖ¼¼¿ä. T.T; °¡´ÉÇÏ¸é ¹öÀü ¸ÂÃç¼­ Å×½ºÆ®ÇØº¸¼¼¿ä. Linux/Unix È¯°æÀÏ °æ¿ì´Â x Window »óÅÂ¿¡¼­ xhost localhost ¶ó°í ÇØÁà¾ß ÇÑ´Ù³×¿ä. ÀÌÂÊÀº ¿ï È¸»ç SE ¶û ¾ê±â¸¦ ÇØºÁ¾ß°Ú³×¿ä. ÀÏ´Ü À©µµ¿ì¿¡¼­ µ¹¸®´Â °Í¸¸ °¡Á¤ÇÏ°Ú½À´Ï´Ù.
		</text>
		<image>/images/spacer.gif
		</image>
	</what>
	<what>
		<text>
		¼Ò½ºÀÇ ÃâÃ³´Â ÇÑºû¹Ìµð¾î¿¡¼­ ³ª¿Â ¼­ºí¸´ÇÁ·Î±×·¡¹Ö Ã¥ÀÔ´Ï´Ù. ¼­ºí¸´ ¼Ò½ºÀÎµ¥, jsp ·Î ¹Ù²Û °Í »ÓÀÔ´Ï´Ù. ¾Æ, ±×Àü¿¡ www.acme.com »çÀÌÆ®¿¡ °¡¼­ ÆÐÅ°Áö¸¦ ´Ù¿î¹Þ¾Æ¿Í¾ßÁö¿ä. http://www.acme.com/java/software/Acme.JPM.Encoders.GifEncoder.html ÀÔ´Ï´Ù.
		</text>
		<image>gifencode01_01.gif
		</image>
	</what>
	<what>
		<text>GifEncoderÀÇ API °¡ ³ª¿É´Ï´Ù. package ÀüÃ¼¸¦ ´Ù¿î¹ÞÀ¸µµ µË´Ï´Ù. Fetch the entire ACME package ¸¦ Å¬¸¯ÇÏ¸é ACME ÆÐÅ°Áö ÀüÃ¼°¡ gzipÀ¸·Î ¾ÐÃàµÈ °ÍÀ» ´Ù¿î¹ÞÀ» ¼ö ÀÖ½À´Ï´Ù. 
		</text>
		<image>gifencode01_02.gif
		</image>
	</what>
	<what>
		<text>´Ù¿î¹ÞÀº Acme.tar.gzÀ» ¾ËÁýÀ» ÀÌ¿ëÇØ¼­ ¾ÐÃàÀ» Ç±´Ï´Ù. ÇÊ¿äÇÑ ÆÄÀÏÀÌ, Acme ¶ó´Â µð·ºÅä¸® ¾È¿¡ JPM µð·ºÅä¸®°¡ ÀÖ°í ±× ¾È¿¡´Â Encoders ¶ó´Â µð·ºÅä¸®°¡ ÀÖ°í ±× ¾È¿¡´Â class ÆÄÀÏÀÌ µÎ°³ ÀÖ½À´Ï´Ù. Acme µð·ºÅä¸®¸¦ WEB-INF\classes ¾Æ·¡·Î ÀÌµ¿ÇÕ´Ï´Ù. ¾îµòÁö ¾Æ½ÃÁÒ? ¾Æ´Ï¸é Á¦°¡ Tips °Ô½ÃÆÇ¿¡ ¿Ã·Á³õÀº Acme.jar ÆÄÀÏÀ» c:\jdk1.3\jre\lib\ext ¿¡ º¹»ç½ÃÄÑ ³õ¾Æµµ µË´Ï´Ù.
		</text>
		<image>gifencode01_03.gif
		</image>
	</what>
	<what>
		<text>
		ÀÌÁ¦ ¼³Ä¡´Â ³¡³µ½À´Ï´Ù. ¼Ò½º¸¦ º¸ÁÒ.

		<¼Ò½º ÆÄÀÏ¸í="imageCall.html">&lt;html>
&lt;body bgcolor="#000000">
&lt;img src="HelloGraphics.jsp">
&lt;/body>
&lt;/html>
		</¼Ò½º>
		<¼Ò½º ÆÄÀÏ¸í="HelloGraphics.jsp">&lt;%@ page import="java.io.*, java.awt.*, Acme.JPM.Encoders.GifEncoder"
%>&lt;%

    Frame frame = null;
    Graphics g = null;

    try {
      // Create an unshown frame
      frame = new Frame();
      frame.addNotify();

      // Get a graphics region, using the Frame
      Image image = frame.createImage(200, 300); // image size width 200, height 300
      g = image.getGraphics();

g.setFont(new Font("Serif", Font.ITALIC, 50)); 
g.drawString("JSP", 10, 50); 
g.drawString("Image!", 10, 80); 
g.setColor(new Color(0x0080AA)); 
g.setFont(new Font("Garamond", Font.PLAIN, 18)); 
g.drawString("www.okjsp.pe.kr", 60, 280); 

      // Encode the off screen image into a GIF and send it to the client
      response.setContentType("image/gif");
      GifEncoder encoder = new GifEncoder(image, response.getOutputStream());
      encoder.encode();
    }
    finally {
      // Clean up resources
      if (g != null) g.dispose();
      if (frame != null) frame.removeNotify();
    }
%>
		</¼Ò½º>
		</text>
		<image>/images/spacer.gif
		</image>
	</what>
	<what>
		<text>
		HelloGraphics.jsp ÆÄÀÏÀº text/html À» »ý¼ºÇØ ³»´Â °ÍÀÌ ¾Æ´Ï¶ó, image/gif Çü½ÄÀÇ ÆÄÀÏÀ» »ý¼ºÇØ ³À´Ï´Ù. ±×·¡¼­ img src="HelloGraphics.jsp" Ã³·³ È£ÃâÇÒ ¼ö ÀÖ´Â °ÍÀÌÁÒ.
		</text>
		<image>HelloGraphics.gif
		</image>
	</what>
	<what>
		<text>
		ÇÑ±ÛÀº ¿©±â¼­µµ ÀÎÄÚµùÀ» ÇØÁà¾ß µÇ´Â ±º¿ä. ÀÌ·¸°Ô º¯°æÇØÁÖ½Ã¸é µË´Ï´Ù.
		<¼Ò½º>
String txt = "ÇÑ±Û, Image!";
txt = new String(txt.getBytes("8859_1"),"euc-kr");
g.setFont(new Font("Gulim", Font.ITALIC, 30)); 
g.drawString("JSP", 10, 50); 
g.drawString(txt, 10, 80); 
</¼Ò½º>
		</text>
		<image>HelloGraphics_kr.gif
		</image>
	</what>
	<what>
		<text>
		¿©±â¿¡ °üÇØ¼­ °ü·ÃÀÚ·áµéÀ» ´õ Ã£¾Æº¸½Ã±â ¹Ù¶ø´Ï´Ù. jpeg »ý¼ºÇÏ´Â ¶óÀÌºê·¯¸®µµ ÀÖ°í, ´Ù¾çÇÏ°Ô ÀÀ¿ëÇÒ ¼ö ÀÖ°ÚÁÒ. ¿äÁò À¯ÇàÇÏ´Â avatar µµ ¸¸µé ¼ö ÀÖ°ÚÁÒ.
		</text>
		<image>/images/spacer.gif
		</image>
	</what>
	<what>
		<text>
		¸¶Áö¸·À¸·Î ¸·´ë±×·¡ÇÁ ÇÏ³ª ±×¸®°í ³¡³»µµ·Ï ÇÏ°Ú½À´Ï´Ù. ¿ø¸®´Â ÀÌ·¸½À´Ï´Ù. ¼ýÀÚµéÀ» ¹è¿­¿¡ ³õ°í ¸Æ½Ã¸Ø °ªÀ» ±¸ÇÕ´Ï´Ù. ÀÌ¹ÌÁö Å©±â¿¡ ¸ÂÃç¼­ ºñÀ²À» °áÁ¤ÇÕ´Ï´Ù. ¹è¿­ÀÇ length ·Î ÀÌ¹ÌÁö ÆøÀ» ³ª´¯´Ï´Ù. ±×¸®°í ±×·ÁÁÖ¸é µË´Ï´Ù. ³­¼ö¸¦ 10 °³ ¸¸µé¾î¼­ µ¿ÀûÀ¸·Î ÀÌ¹ÌÁö¸¦ »ý¼ºÇØº¸µµ·Ï ÇÏ°Ú½À´Ï´Ù.
		</text>
		<image>/images/spacer.gif
		</image>
	</what>
	<what>
		<text>
		<¼Ò½º ÆÄÀÏ¸í="HelloGraphics.jsp">&lt;%@ page import="java.util.*, java.io.*, java.awt.*, Acme.JPM.Encoders.GifEncoder"
%>&lt;%

// °è»ê
// ³­¼ö ¹ß»ý
	double [] num = new double[10];
	for(int i=0;i&lt;num.length; i++) {
		num[i] = Math.random() * 100;
	}
// ÃÖ´ë°ª
	double max=num[0] ;
	for(int i=1;i&lt;num.length;i++) {
		if(max&lt;num[i])
			max=num[i];
	}
	
	int margin = 10;
	float x_pace = (300-margin*2) / (float)10;
	float y_height = (float)(200-margin*2);
	double ratio = y_height / max;


    Frame frame = null;
    Graphics g = null;

    try {
      // Create an unshown frame
      frame = new Frame();
      frame.addNotify();

      // Get a graphics region, using the Frame
      Image image = frame.createImage(300, 200); // image size width 300, height 200
      g = image.getGraphics();

g.setColor(new Color(0x0040FF)); 
g.setFont(new Font("System", Font.PLAIN, 11)); 
g.drawString("www.okjsp.pe.kr", 210, 198); 
g.drawString("Max:"+max, 10, 198); 

// draw Bars
int xx = 0;
int yy = 0;

g.setColor(new Color(0x000000)); 
g.drawRect(0,0,299,199);
for (int i=0; i&lt;num.length; i++) {
	xx = (int)(i * x_pace) + margin;
	yy = (int)(num[i] * ratio);
	yy = 200 - (yy + margin); 
	
	g.drawRect(xx, yy, (int)x_pace-3, 188 - yy);
	g.drawString(""+(int)num[i], xx+9, yy);
}

      // Encode the off screen image into a GIF and send it to the client
      response.setContentType("image/gif");
      GifEncoder encoder = new GifEncoder(image, response.getOutputStream());
      encoder.encode();
    }
    finally {
      // Clean up resources
      if (g != null) g.dispose();
      if (frame != null) frame.removeNotify();
    }
%>
</¼Ò½º>
		</text>
		<image>HelloGraphics2.gif
		</image>
	</what>
	<what>
		<text>
		¿À´Ã °­ÁÂ°¡ ¸¹Àº µµ¿òÀÌ µÇ±æ ¹Ù¶ø´Ï´Ù. ¹ãÀ» »õ¹ö·È³×¿ä. ³»ÀÏ È¸»ç°¡¼­ Á¹Áö³ª ¾ÊÀ»·¡³ª....
		</text>
		<image>/images/spacer.gif
		</image>
	</what>
	
	
	<refer>
	<link>http://www.acme.com/</link>
	<comment>°­ÁÂ¿¡¼­ ¼Ò°³ÇÑ »çÀÌÆ®ÀÔ´Ï´Ù.</comment>
	</refer>

	<refer>
	<link>http://www.acme.com/java/software/Acme.JPM.Encoders.GifEncoder.html</link>
	<comment>´Ù¿î¹ÞÀ» ¼ö ÀÖ´Â °÷ÀÔ´Ï´Ù.</comment>
	</refer>

	<refer>
	<link><![CDATA[http://www.4offline.org/bbs/view.php?id=Tip&page=1&page_num=20&category=&sn=off&ss=off&sc=off&keyword=&select_arrange=headnum&desc=asc&no=33]]></link>
	<comment>4offline : [JSP] ÀÌ¹ÌÁö ¸¸µé¾î¼­ È­¸é¿¡ »Ñ¸®±â.</comment>
	</refer>
</lecture>
