À̹ø°­Á¿¡¼­´Â parameter ¸¦ °®´Â ű׿¡ ´ëÇؼ­ ¾Ë¾Æº¸µµ·Ï ÇÏ°Ú´Ù.

 

Áö³­°­Á¿¡¼­ ¾Ë ¼ö ÀÖµíÀÌ ´Ü¼øÇÑ Å±×Á¶Â÷µµ ¸¹Àº ¸Å¼­µå¸¦ ½á¾ß ÇÑ´Ù´Â °ÍÀ» ¾Ë¼ö ÀÖ¾ú´Ù.

»ç½Ç Áö³­½Ã°£±îÁö´Â Tag ÀÎÅÍÆäÀ̽º¸¦ »ç¿ëÇß½À´Ï´Ù.

ÀÎÅÍÆäÀ̽º´Â ±× Ư¼º»ó ¸ðµç ¸Þ¼­µå¸¦ ÀÏÀÏÀÌ »ç¿ëÀÚ°¡ ±¸ÇöÀ» ÇØ¾ß ÇÔÀ» ÀǹÌÇÑ´Ù.

À̹ø °­Á¿¡¼­´Â ÀÌ·¯ÇÑ Tag ÀÎÅÍÆäÀ̽º¸¦ ¹Ì¸® ±¸ÇöÇÑ TagSupportŬ·¡½º¸¦ ÀÌ¿ëÇÏ¿© ÁøÇàÇϵµ·Ï ÇÏ°Ú½À´Ï´Ù.

 

±×·³. TagSupportŬ·¡½ººÎÅÍ »ìÆ캸µµ·Ï ÇÏÁÒ..

 

Javax.servlet.jsp.tagext.TagSupport

#id:java.lang.String
#pageContext:javax.servlet.jsp.PageContext
-paret:javax.servlet.jsp.tagext.Tag

-values:java.lang.Objct[]

+getId():java.lang.String

+setId(:java.lang.String):void

+release():void

+getValue(:java.lang.String):java.lang.Object

+setValue(:java.lang.String,:java.lang.Object):void

+getParent():javax.servlet.jsp.tagext.Tag

+setParent(:javax.servlet.jsp.tagext.Tag):void

+TagSupport()

+findAncestorWithClass(:javax.servlet.jsp.tagext.Tag,..)

+getValues():java.util.Enumeration

+removeValue(:java.lang.String):void

+doEndTag():int

+doStarttag():int

+setPageContent(:javax.servlet.jsp.PageContext):void

 

Interface

Javax.servlet.jsp.tagext

 

 

 

TagSupport Ŭ·¡½º Áß¿¡¼­ ¸î°¡Áö ¸Þ¼­µå¸¦ »ìÆ캸µµ·Ï ÇÏ°Ú½À´Ï´Ù.

- findAncestorsWithClass() : ºÎ¸ðű׸¦ ã´Â´Ù.

- getID / setID() : ID¶ó´Â ÆĶó¹ÌÅ͸¦ ¼ÂÆÃÇϰųª °ªÀ» °¡Á®¿À´Âµ¥ »ç¿ëµÇ´Â ¸Þ¼­µå

 

I.                    Hello Tag ÀÇ ÀÛ¼º

 

¿ì¸®´Â TagSupportŬ·¡½º¸¦ »ó¼Ó¹Þ¾Æ Tag¸¦ ÀÛ¼ºÇÏ·Á ÇÕ´Ï´Ù.

´ÙÀ½ÀÇ µµÇ¥·Î ±âº» ±¸Á¶¸¦ »ìÆ캸µµ·Ï ÇÏ°Ú½À´Ï´Ù.

 

tag.HelloTag

-name:String = ¡°¡±

+HelloTag()

+setName(name:String):void

+doEndTag():int

 

javax.servlet.jsp.tagext.TagSupport

 

 

1.        ÅÂ±× Çڵ鷯 Ŭ·¡½ºÀÇ ÀÛ¼º

<HelloTag.java>

package tag;

import javax.servlet.jsp.*;

import javax.servlet.jsp.tagext.*;

public class HelloTag extends TagSupport{

       private String name = ¡°¡±;

       // »ý¼ºÀÚ

       public HelloTag(){ super();}

       // setter ¸Þ¼­µå

       public void setName(String name){

                    this.name = name;

       }

       public int doEndTag() throws javax.servlet.jsp.JspTagException{

                    try{

                                 pageContext.getOut().write(¡°Hello ¡° + name + ¡°!¡±);

                    }catch(java.io.IOException e){

                                 throw new JspTagException(¡°IO Error : ¡° + e.getMessage());

                    }

                    return EVAL_PAGE;

}

}

 

ÀÌÀü°­Á¿¡¼­ »ç¿ëÇß´ø ¸Þ¼­µåµéÀÌ ¸¹ÀÌ »ç¶óÁø °ÍÀ» ¾Ë¼ö Àִµ¥ ¾Õ¼­ ¾ð±ÞÇßµíÀÌ..

TagSupportŬ·¡½º´Â Tag ÀÎÅÍÆäÀ̽º¸¦ ±¸ÇöÇÑ Å¬·¡½ºÀ̹ǷΠ¸ðµç ¸Þ¼­µå¸¦ ±¸ÇöÇÒ ÇÊ¿ä°¡ ¾ø½À´Ï´Ù.

2.        ű׼³¸íÀÚ µî·Ï

<mytag.tld> ¿¡ µî·Ï

<tag>

<name>hello</name>
<tagclass>tag.HelloTag</tagclass>
<bodycontent>empty</bodycontent>
<info>A Hello Tag</info>
<attribute>

<name>name</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>

</attribute>

</tag>

 

3.        Presentation ÀÛ¼º(JSP ÆÄÀÏ ÀÛ¼º)

<hello.jsp>

<%@ taglib uri="taglibExample" prefix="mt" %>
<HTML>

<HEAD>

<TITLE>Hello!</TITLE>

</HEAD>
<BODY BGCOLOR="#FFFFFF">

<HR>
<mt:hello name="foo"/>
<HR>

</BODY>

</HTML>

 

4.        °á°ú È®ÀÎ

http://localhost/tag_tu/hello.jsp

 

             ´ÙÀ½°­Á¿¡¼­´Â Body¸¦ °®´Â ű׿¡ ´ëÇؼ­ ¾Ë¾Æº¸µµ·Ï ÇÏ°Ú½À´Ï´Ù.