JSP Directive

 

Directive Tag´Â End UserÀÇ ´«¿¡´Â Ãâ·ÂÀ¸·Î ³ªÅ¸³ªÁö ¾Ê°í, ±× ´ë½Å JSP Container°¡ ÆäÀÌÁö¸¦ ó¸®ÇÏ´Â ½ºÅ¸ÀÏÀ» º¯°æ½ÃÅ°´Â ºÎ°¡Àû È¿°ú¸¦ ¹ß»ý½Ãŵ´Ï´Ù.

 

1. Page Directive

ÇØ´ç JSP Page¿¡ Àû¿ëµÇ´Â ¼Ó¼º Á¤ÀÇ

 

Snytax

<%@ page 
       [ language="
java" ]
       [ extends="package.class" ]
      
[ import= "{ package.class | package.* }, ..." ]
      
[ session="true|false" ]
       [ buffer="none|8kb|sizekb" ]
       [ autoFlush="true|false" ]
       [ isThreadSafe="true|false" ]
       [ info="text" ]
       [ errorPage="relativeURL" ]
       [ contentType="mimeType [ ;charset=characterSet ]" |
                   
"text/html ; charset=euc-kr" ]
       [ isErrorPage="true|false" ]
%>

 

Examples

<%@ page import=¡±java.util.*,java.lang.*¡± %>

<%@ page contentType="text/html;charset=euc-kr" %>

<%@ page errorPage=¡±error.jsp¡± %>


Description

JSP ÆÄÀÏ or Include ÆÄÀÏÀÇ À§Ä¡¿¡ ´ëÇÑ Á¦¾àÀº ¾øÁö¸¸ Ç×»ó ¸ÇÀ§¿¡ ¼±¾ðÇÏ´Â °ÍÀÌ ÁÁ½À´Ï´Ù.

Attributes

11°¡ÁöÀÇ ¼Ó¼º Áß Áß¿äÇÑ ºÎºÐ¿¡ ´ëÇÑ Á¤¸®¸¸ Çϵµ·Ï ÇÏ°Ú½À´Ï´Ù.

- info ¼Ó¼º
ÇØ´ç ÆäÀÌÁöÀÇ ¿ªÇÒÀ» ¼³¸íÇØ ÁÖ´Â document ¹®ÀÚ¿­À» Ãß°¡ÇÒ ¼ö ÀÖ½À´Ï´Ù.
<%@page info=
¡± iHelpers WebSite, by SSM¡±>


- ContentType ¼Ó¼º
JSP Page°¡ »ý¼ºÇÏ´Â ÀÀ´äÀÇ MIME ( Multipurpose Internet Mail Extension ) ŸÀÔ°ú Character SetÀ» ÁöÁ¤ÇÕ´Ï´Ù. MIMEÀº HTTP ÀÀ´ä¿¡ ´ã±â´Â Á¤º¸ÀÇ Å¸ÀÔÀ» ÁöÁ¤ÇÒ ¶§¿¡ »ç¿ëµÇ¸ç ±âº»ÀûÀ¸·Î ¼³Á¤µÈ MIMEÀº text/html , Character Set Àº ISO-8859-1
<%@page contentType=¡±image/gif¡±>
<%@ page contentType=
¡±text/xml¡±>

- import ¼Ó¼º
ÇØ´ç Package¸¦ JSP ÆÄÀÏ¿¡¼­ ÂüÁ¶ÇÏ¿© »ç¿ëÇÒ ¼ö ÀÖµµ·Ï ¼±¾ðÇÕ´Ï´Ù.

<%@ page import=
¡±java.util.List, java.awt.List¡± %> ÀÇ °æ¿ì´Â °°Àº À̸§À» µÎ ¹ø import¸¦ »ç¿ëÇÏ¿´±â¿¡ JSP ContainerÀÇ ÀÔÀå¿¡¼­´Â ¡°¸ðÈ£¼ºÀÌ ÀÖ´Â À߸øµÈ ¹®À塱 À¸·Î °£ÁÖÇϱ⿡ ¾Æ·¡¿Í °°ÀÌ ¼±¾ðÇØ ÁÖ¾î¾ß ÇÕ´Ï´Ù.
<%@ page import=
¡±java.util.*, java.awt.List¡± %>
ÀÌ¿Í °°ÀÌ ¼±¾ðÇϸé java.awtÀÇ List Class´Â ±âº» À̸§À¸·Î ÂüÁ¶ÇÒ ¼ö ÀÖÁö¸¸, java.util ÀÇ °æ¿ìÀÇ List´Â full nameÀ¸·Î Á¢±ÙÇØ¾ß ÇÕ´Ï´Ù.  java.util.List ·Î

java.lang, javax.servlet, javax.servlet.http, javax.servlet.jsp ´Â ±âº»ÀûÀ¸·Î import µÇ¾î ÀÖ½À´Ï´Ù.

ÀÌ¿Ü¿¡ session, buffer,autoFlush .. ¼Ó¼ºÀº reference¸¦ ÂüÁ¶ÇØ ÁֽʽÿÀ.



2. include Directive

JSP Code ÆÄÀÏ ¶Ç´Â Text ÆÄÀÏÀ» include ÇÏ·Á°í ÇÒ °æ¿ì »ç¿ëÇÕ´Ï´Ù.  ½±°Ô À̾߱â Çϸé C, PHP, Perl ,ASP ÀÇ include ÆÄÀÏ·Î µ¿ÀÏÇÕ´Ï´Ù.

 

Syntax

<%@ include file=¡±relativeURL¡± %>

 

Example

ex3.jsp

<%@ page contentType="text/html;charset=euc-kr" %>

<HTML>

<BODY>

The Current Date and Time are

<%@ include file="date.jsp" %>

<%@ include file="copyright.html" %>

</BODY>

</HTML>

 

date.jsp

<%@ page import="java.util.*" %>

<%="["+ (new java.util.Date()).toLocaleString()+"]" %>

 

copyright.html

<hr>

Copyright ¨Ï 2000-2001 ihelpers. All Right Reserved. E-mail : webmaster@ihelpers.co.kr ¢Ï 02-928-8364

 

Description

°¡Àå Áß¿äÇÑ Á¡Àº includeµÇ´Â ½ÃÁ¡ÀÌ ÇØ´ç JSP Page°¡ Servlet Source Code·Î ÆĽ̵ǰí ÄÄÆÄÀϵDZâ Àü¿¡ ÀϾ´Ù´Â Á¡ÀÔ´Ï´Ù. ÀÌ¿Í °°±â¿¡ include process´Â static À̶ó°í À̾߱â ÇÕ´Ï´Ù. Ãß°¡µÇ´Â ÆÄÀÏÀÇ ³»¿ëÀÌ Á¤ÀûÀÎ ³»¿ëÀÌ Ãß°¡µÇ±â ¶§¹®ÀÔ´Ï´Ù. JSP ÆÄÀÏÀ» Ãß°¡ ½Ã¿¡µµ ÇØ´ç JSP TagsµéÀ» ÆĽÌÇÑ ÈÄ ÇØ´ç °á°ú¸¦ include ÇÕ´Ï´Ù.

ÇØ´ç Page³»ÀÇ include ÆÄÀÏÀÌ º¯°æµÇ¾úÀ» °æ¿ì´Â ÀçÄÄÆÄÀÏÀ» ÇÕ´Ï´Ù.

( ÀÌ ºÎºÐÀº JSP Container ¸¶´Ù Â÷ÀÌ°¡ ÀÖ´Â °Í °°´õ¶ó±¸¿ä. Á¤È®½Ã ¾ÊÀ½¡¦ )

 

 

3. Taglib Directive

ÇÑ °³ ÀÌ»óÀÇ Custom Tag Library ¿¡ ÀÇÁ¸ÇÏ°í ÀÖ´Ù´Â °ÍÀ» JSP Container¿¡¼­ ¾Ë·ÁÁÙ ¶§ »ç¿ëÇÕ´Ï´Ù.

 

Snytax

<%@ taglib uri="URIToTagLibrary"  prefix="tagPrefix" %>

Taglib Directive´Â Custom Tag¿¡ ´ëÇÏ¿© À̾߱â ÇÒ ¶§ ÀÚ¼¼È÷ ¾Ëµµ·Ï ÇÏÁö¿ä.

 

°­ÁÂÀÇ reference

- Web Development with Java Server Pages. by Duane K. Fields & Mark A. Kolb ,°û¿ëÀçÆí¿ª ; InfoBook, Manning

-  http://java.sun.com/products/jsp/tags/tags.html

-  http://myhome.shinbiro.com/~jimmy/home.htm