티스토리 뷰

JSP

JSP Directive Elements

carrot62 2020. 8. 4. 14:13

JSP directives는 container안의 내용에 명령을 전달하는 역할을 해서 각 container들이 JSP processing을 할때 어떻게 데이터를 handle 해야하는지를 말해준다.

<%@ directive attribute = "value" %>

3 가지의 directive tag가 존재한다:

  • JSP page directive: Defines page-dependent attributes(예: scripting 언어 설정, error page, buffering requirements 등...)
    • <%@ page ... %>
  • JSP include directive: Includes a file during the transition phase, 웹 페이지에서 다음 페이지로 넘어가도 공통되게 사용되는 부분들을 고정할 때도 쓰인다
    • <%@ include ...%>
  • JSP taglib directive : Declares a tag library, containing custom actions used in the page
    • <%@ taglib ... %>

  JSP Page Directive  

현재 페이지에 속해 있는 container 명령어이다. 보통 페에지 맨 위애 정의된다.

  1. import : 특정 class를 사용하고 싶을 때 사용한다, 여기서 "value"부분은 우리가 불러오기 하고 싶은 패키지의 이름이다
  2. contentType: MIME(Multipurpose Internet Maril Extension)
  3. buffer : buffer 크기를 변경할 때 사용된다 (기본 크기는 8kb이다)
  4. autoFlush
  5. contentType
  6. errorPage: 에러가 날때 이동할 페이지를 지정한다.
  7. isErrorPage: Error page의 여부를 판달할 때 사용된다
  8. extends : defines the parent class that will be inherited by the generated servlet(잘 사용되지 않는다)
  9. import
  10. info : sets the info. of the JSP page which is retrieved later using getServletInfo() 
  11. isThreadSafe
  12. language
  13. session
  14. isELIgnored: EL(Expression Language) 표현을 ignore하게 하는 것
        사용) isELIgnored= "true"
  15. isScriptingEnabled

 

  JSP Include Directive  

JSP는 (한번 interpret되고 나면)재사용이 가능하기 때문에 속도면에서 빠르다는 장점이 있다. PHP에서는 client로부터 요청이 올 때 마다 계속해서 해석을 해서 보내줘야하기 때문에 비효율적이다.

<html>  
<body>  
  
<%@ include file="header.html" %>  
  
Today is: <%= java.util.Calendar.getInstance().getTime() %>  
  
</body>  
</html> 
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h1>This is a header file</h1>
	<p>If you see this message, this means that the "include" directive
	has successfully included "header.html"</p>
</body>
</html>

성공적으로 된다면:

 

  JSP Taglib Directive  

TLD(Tag Library Descriptor)를 이용해서 tag를 정의한다.

<%@ taglib uri="uriofthetaglibrary" prefix="prefixoftaglibrary" %>  

 

'JSP' 카테고리의 다른 글

JSP: EL  (0) 2020.08.07
JSP Action tags와 Javabean 사용법  (0) 2020.08.06
Development in JSP  (0) 2020.08.06
JSP Project Hosting  (0) 2020.08.06
JSP 기초  (0) 2020.08.03