SlideShare una empresa de Scribd logo
1 de 19
Slide 1 of 29
Introduction to Custom Tags
Classic tag
Slide 2 of 29
Overview
 Custom Tags
 Various type of Custom Tags
 Components of Tag Library
 javax.servlet.jsp.tagext package
 Common methods of Custom Tags
Slide 3 of 29
Custom Tags
 Allow Java programmer to embed Java
codes in JSP documents
 Provide a mechanism to reuse and
encapsulate complex recurring code or
tasks in JSP
 Provide simplicity and reusability of Java
code
 Structure of custom tags in JSP is similar to
XML tags
Slide 4 of 29
Various Types of Custom Tag
 Empty tags
<td:welcome />
 Tags with attributes
<td: welcome color=”blue”></td:welcome>
 Tags with a body
<td: welcome>
<%=today_date%>
</td:welcome>
 Nested tags
<td1:ifTag condition “<%=eval>“ >
<td2:valueTrue>The expression evaluates to true
Slide 5 of 29
Component of Tag Library
 Tag Handler
 Tag Library Descriptor [TLD]
 Tag File
Slide 6 of 29
Mechanisms for building custom tags
 Tag Handler
 Tag files
Slide 7 of 29
Mechanisms for building custom tags
 Tag Handler
– Classic Tag
– Simple Tag
Slide 8 of 29
Classic Tag
Slide 9 of 29
javax.servlet.jsp.tagext package
– Classic Custom Tag
Classic tags is a JSP 1.2 technology. The
classic tag handler class can be created by
extending implementing .
• Tag
• IterationTag
• BodyTag
• TagSupport
• BodyTagSupport
Slide 10 of 29
tagext package
 Tag - Interface
– Is the base tag handler interface that defines
the methods required by all tag handlers
• public int doStartTag() throws JspException
• public int doEndTag() throws JspException
• public void release()
 IterationTag - Interface
– Used when a custom tag needs to repeatedly
re-evaluate its body
– Useful for looping through a collection of
Objects without using a scriptlet
• public int doAfterBody() throws JspException
Slide 11 of 29
tagext package
 BodyTag - Interface
– Provide features for manipulating the body content
• public void doInitBody() throws JspException
• public void setBodyContent(BodyContent b)
 BodyContent - Class
– Is a subclass of the JSPWriter class
– represents the body content of a tag
 TagSupport - Class
– Implements the Tag and IterationTag Interfaces.
– Supports tag and a tag with body iterations
Slide 12 of 29
tagext package
 BodyTagSupport - Class
– Sub class of TagSupport & implements BodyTag
– used to develop custom tags with body
Slide 13 of 29
Tag Library Descriptor [TLD]
 Is an xml file that contains the tag library
description
 Contains the list and description of all custom
tags in the library
 Provides the JSP engine with meta-information
about the custom tag and about its
implementation
 Components of the TLD classified into two
groups
<taglib> </taglib>
<tag> </tag>
Slide 14 of 29
Structure of TLD file
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>first</shortname>
<info>Example of a tag</info>
<tag>
<name>welcome</name>
<tagclass>TestTag</tagclass>
<bodycontent>JSP</bodycontent>
<info>An example</info>
</tag>
</taglib>
Slide 15 of 29
Execution of JSP with Custom Tags
Execution Cycle of a JSP file with Custom Tags
Slide 16 of 29
Deploying and Using Custom Tags
 Create a Tag Library Descriptor (.tld) file in the tlds folder
inside WEB-INF
 Create a Tag Handler class in proper package with tld file.
 Include taglib directive in target JSP page
 Use the custom tag
Slide 17 of 29
tagext package
 Returns value of doStartTag()
– SKIP_BODY
– EVAL_BODY_INCLUDE
– EVAL_BODY_BUFFERED
 Return value of doEndTag()
– SKIP_PAGE
– EVAL_PAGE
 Return value of doAfterBody()
– SKIP_BODY
– EVAL_BODY_AGAIN
Slide 18 of 29
Tag Life Cycle
Instantiate Tag
Handler
doStartTag()
doEndTag()
return
value
setBodyContent()
doInitBody()
doAfterBody()
return
value
Evaluate
Body
return
value
Evaluate rest
of the Page
Return from
current page
EVAL_BODY_BUFFERED
EVAL_BODY_INCLUD
E
SKIP_BODY
SKIP_BODY
EVAL_BODY_AGAIN
SKIP_PAGE
EVAL_PAGE
Slide 19 of 29
Summary
 Custom Tags
 Various type of Custom Tags
 Components of Tag Library
 javax.servlet.jsp.tagext package
 Common methods of Custom Tags
 Tag life cycle
 Tag Library Descriptor
 Execution of JSP with Custom Tags
 Deploying and Using Custom Tags

Más contenido relacionado

Destacado

Rename domain controller server 2012
Rename domain controller server 2012Rename domain controller server 2012
Rename domain controller server 2012laonap166
 
Mcsa 2012 local user and group
Mcsa 2012 local user and groupMcsa 2012 local user and group
Mcsa 2012 local user and grouplaonap166
 
Cài đặt exchange server 2013
Cài đặt exchange server 2013Cài đặt exchange server 2013
Cài đặt exchange server 2013laonap166
 
Mcsa 2012 file server và share permission
Mcsa 2012 file server và share permissionMcsa 2012 file server và share permission
Mcsa 2012 file server và share permissionlaonap166
 
BÀI 10 : Nâng cao hiệu quả hoạt động cơ sở dữ liệu
BÀI 10 : Nâng cao hiệu quả hoạt động cơ sở dữ liệuBÀI 10 : Nâng cao hiệu quả hoạt động cơ sở dữ liệu
BÀI 10 : Nâng cao hiệu quả hoạt động cơ sở dữ liệuMasterCode.vn
 
Windows routing phần 2
Windows routing phần 2Windows routing phần 2
Windows routing phần 2laonap166
 
CVNguyenThanhLam-102015-Vi
CVNguyenThanhLam-102015-ViCVNguyenThanhLam-102015-Vi
CVNguyenThanhLam-102015-ViLam Nguyen
 
ScrumDay Vietnam 2012 - Scrum with Team Foundation Server - Quang
ScrumDay Vietnam 2012 - Scrum with Team Foundation Server - QuangScrumDay Vietnam 2012 - Scrum with Team Foundation Server - Quang
ScrumDay Vietnam 2012 - Scrum with Team Foundation Server - QuangDUONG Trong Tan
 
Mcsa 2012 monitor server performance
Mcsa 2012 monitor server performanceMcsa 2012 monitor server performance
Mcsa 2012 monitor server performancelaonap166
 
Bài 6 CỤM HỆ THỐNG
Bài 6 CỤM HỆ THỐNGBài 6 CỤM HỆ THỐNG
Bài 6 CỤM HỆ THỐNGMasterCode.vn
 
Mcsa 2012 domain network
Mcsa 2012 domain networkMcsa 2012 domain network
Mcsa 2012 domain networklaonap166
 
Cấu hình dhcp failover trên windows server 2012
Cấu hình dhcp failover trên windows server 2012Cấu hình dhcp failover trên windows server 2012
Cấu hình dhcp failover trên windows server 2012laonap166
 
Triển khai nhiều domain controller chạy song song trên windows server 2012
Triển khai nhiều domain controller chạy song song trên windows server 2012Triển khai nhiều domain controller chạy song song trên windows server 2012
Triển khai nhiều domain controller chạy song song trên windows server 2012laonap166
 
Cài đặt và cấu hình dhcp server trên windows server 2012
Cài đặt và cấu hình dhcp server trên windows server 2012Cài đặt và cấu hình dhcp server trên windows server 2012
Cài đặt và cấu hình dhcp server trên windows server 2012laonap166
 
Bài 3: Làm việc với kiểu dữ liệu và mã kịch bản - Giáo trình FPT
Bài 3: Làm việc với kiểu dữ liệu và mã kịch bản - Giáo trình FPTBài 3: Làm việc với kiểu dữ liệu và mã kịch bản - Giáo trình FPT
Bài 3: Làm việc với kiểu dữ liệu và mã kịch bản - Giáo trình FPTMasterCode.vn
 
BÀI 4: Lệnh lựa chọn và quy trình phát triển phần mềm - Giáo trình FPT
BÀI 4: Lệnh lựa chọn và quy trình phát triển phần mềm - Giáo trình FPTBÀI 4: Lệnh lựa chọn và quy trình phát triển phần mềm - Giáo trình FPT
BÀI 4: Lệnh lựa chọn và quy trình phát triển phần mềm - Giáo trình FPTMasterCode.vn
 

Destacado (16)

Rename domain controller server 2012
Rename domain controller server 2012Rename domain controller server 2012
Rename domain controller server 2012
 
Mcsa 2012 local user and group
Mcsa 2012 local user and groupMcsa 2012 local user and group
Mcsa 2012 local user and group
 
Cài đặt exchange server 2013
Cài đặt exchange server 2013Cài đặt exchange server 2013
Cài đặt exchange server 2013
 
Mcsa 2012 file server và share permission
Mcsa 2012 file server và share permissionMcsa 2012 file server và share permission
Mcsa 2012 file server và share permission
 
BÀI 10 : Nâng cao hiệu quả hoạt động cơ sở dữ liệu
BÀI 10 : Nâng cao hiệu quả hoạt động cơ sở dữ liệuBÀI 10 : Nâng cao hiệu quả hoạt động cơ sở dữ liệu
BÀI 10 : Nâng cao hiệu quả hoạt động cơ sở dữ liệu
 
Windows routing phần 2
Windows routing phần 2Windows routing phần 2
Windows routing phần 2
 
CVNguyenThanhLam-102015-Vi
CVNguyenThanhLam-102015-ViCVNguyenThanhLam-102015-Vi
CVNguyenThanhLam-102015-Vi
 
ScrumDay Vietnam 2012 - Scrum with Team Foundation Server - Quang
ScrumDay Vietnam 2012 - Scrum with Team Foundation Server - QuangScrumDay Vietnam 2012 - Scrum with Team Foundation Server - Quang
ScrumDay Vietnam 2012 - Scrum with Team Foundation Server - Quang
 
Mcsa 2012 monitor server performance
Mcsa 2012 monitor server performanceMcsa 2012 monitor server performance
Mcsa 2012 monitor server performance
 
Bài 6 CỤM HỆ THỐNG
Bài 6 CỤM HỆ THỐNGBài 6 CỤM HỆ THỐNG
Bài 6 CỤM HỆ THỐNG
 
Mcsa 2012 domain network
Mcsa 2012 domain networkMcsa 2012 domain network
Mcsa 2012 domain network
 
Cấu hình dhcp failover trên windows server 2012
Cấu hình dhcp failover trên windows server 2012Cấu hình dhcp failover trên windows server 2012
Cấu hình dhcp failover trên windows server 2012
 
Triển khai nhiều domain controller chạy song song trên windows server 2012
Triển khai nhiều domain controller chạy song song trên windows server 2012Triển khai nhiều domain controller chạy song song trên windows server 2012
Triển khai nhiều domain controller chạy song song trên windows server 2012
 
Cài đặt và cấu hình dhcp server trên windows server 2012
Cài đặt và cấu hình dhcp server trên windows server 2012Cài đặt và cấu hình dhcp server trên windows server 2012
Cài đặt và cấu hình dhcp server trên windows server 2012
 
Bài 3: Làm việc với kiểu dữ liệu và mã kịch bản - Giáo trình FPT
Bài 3: Làm việc với kiểu dữ liệu và mã kịch bản - Giáo trình FPTBài 3: Làm việc với kiểu dữ liệu và mã kịch bản - Giáo trình FPT
Bài 3: Làm việc với kiểu dữ liệu và mã kịch bản - Giáo trình FPT
 
BÀI 4: Lệnh lựa chọn và quy trình phát triển phần mềm - Giáo trình FPT
BÀI 4: Lệnh lựa chọn và quy trình phát triển phần mềm - Giáo trình FPTBÀI 4: Lệnh lựa chọn và quy trình phát triển phần mềm - Giáo trình FPT
BÀI 4: Lệnh lựa chọn và quy trình phát triển phần mềm - Giáo trình FPT
 

Similar a Session 9 : intro to custom tags-classic tag - Giáo trình Bách Khoa Aptech

Advance java session 15
Advance java session 15Advance java session 15
Advance java session 15Smita B Kumar
 
Implementing jsp tag extensions
Implementing jsp tag extensionsImplementing jsp tag extensions
Implementing jsp tag extensionsSoujanya V
 
Implementing java server pages standard tag library v2
Implementing java server pages standard tag library v2Implementing java server pages standard tag library v2
Implementing java server pages standard tag library v2Soujanya V
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 8 ...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 8 ...Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 8 ...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 8 ...WebStackAcademy
 
Standards For Java Coding
Standards For Java CodingStandards For Java Coding
Standards For Java CodingRahul Bhutkar
 
jstl ( jsp standard tag library )
jstl ( jsp standard tag library )jstl ( jsp standard tag library )
jstl ( jsp standard tag library )Adarsh Patel
 
Jsp standard tag_library
Jsp standard tag_libraryJsp standard tag_library
Jsp standard tag_libraryKP Singh
 
Terraform modules restructured
Terraform modules restructuredTerraform modules restructured
Terraform modules restructuredAmi Mahloof
 
Terraform Modules Restructured
Terraform Modules RestructuredTerraform Modules Restructured
Terraform Modules RestructuredDoiT International
 

Similar a Session 9 : intro to custom tags-classic tag - Giáo trình Bách Khoa Aptech (20)

Advance java session 15
Advance java session 15Advance java session 15
Advance java session 15
 
Implementing jsp tag extensions
Implementing jsp tag extensionsImplementing jsp tag extensions
Implementing jsp tag extensions
 
JSP custom tags
JSP custom tagsJSP custom tags
JSP custom tags
 
JSP : Creating Custom Tag
JSP : Creating Custom Tag JSP : Creating Custom Tag
JSP : Creating Custom Tag
 
Jsp tag library
Jsp tag libraryJsp tag library
Jsp tag library
 
Session_15_JSTL.pdf
Session_15_JSTL.pdfSession_15_JSTL.pdf
Session_15_JSTL.pdf
 
Jsp session 9
Jsp   session 9Jsp   session 9
Jsp session 9
 
Jstl 8
Jstl 8Jstl 8
Jstl 8
 
Implementing java server pages standard tag library v2
Implementing java server pages standard tag library v2Implementing java server pages standard tag library v2
Implementing java server pages standard tag library v2
 
Jsplecture
JsplectureJsplecture
Jsplecture
 
Jsp lecture
Jsp lectureJsp lecture
Jsp lecture
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 8 ...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 8 ...Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 8 ...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 8 ...
 
Standards For Java Coding
Standards For Java CodingStandards For Java Coding
Standards For Java Coding
 
JSTL.pptx
JSTL.pptxJSTL.pptx
JSTL.pptx
 
jstl ( jsp standard tag library )
jstl ( jsp standard tag library )jstl ( jsp standard tag library )
jstl ( jsp standard tag library )
 
Xml session
Xml sessionXml session
Xml session
 
Jsp standard tag_library
Jsp standard tag_libraryJsp standard tag_library
Jsp standard tag_library
 
Java se7 features
Java se7 featuresJava se7 features
Java se7 features
 
Terraform modules restructured
Terraform modules restructuredTerraform modules restructured
Terraform modules restructured
 
Terraform Modules Restructured
Terraform Modules RestructuredTerraform Modules Restructured
Terraform Modules Restructured
 

Más de MasterCode.vn

Pd ftai lieu-tieng-anh-cho-nguoi-moi-bat-dau-mastercode.vn
Pd ftai lieu-tieng-anh-cho-nguoi-moi-bat-dau-mastercode.vnPd ftai lieu-tieng-anh-cho-nguoi-moi-bat-dau-mastercode.vn
Pd ftai lieu-tieng-anh-cho-nguoi-moi-bat-dau-mastercode.vnMasterCode.vn
 
Why apps-succeed-wpr-mastercode.vn
Why apps-succeed-wpr-mastercode.vnWhy apps-succeed-wpr-mastercode.vn
Why apps-succeed-wpr-mastercode.vnMasterCode.vn
 
Dzone performancemonitoring2016-mastercode.vn
Dzone performancemonitoring2016-mastercode.vnDzone performancemonitoring2016-mastercode.vn
Dzone performancemonitoring2016-mastercode.vnMasterCode.vn
 
Google công bố thông tin lịch xu hướng ngành 2017 mastercode.vn
Google công bố thông tin lịch xu hướng ngành 2017 mastercode.vnGoogle công bố thông tin lịch xu hướng ngành 2017 mastercode.vn
Google công bố thông tin lịch xu hướng ngành 2017 mastercode.vnMasterCode.vn
 
Nghiên cứu về khách hàng mastercode.vn
Nghiên cứu về khách hàng mastercode.vnNghiên cứu về khách hàng mastercode.vn
Nghiên cứu về khách hàng mastercode.vnMasterCode.vn
 
Lập trình sáng tạo creative computing textbook mastercode.vn
Lập trình sáng tạo creative computing textbook mastercode.vnLập trình sáng tạo creative computing textbook mastercode.vn
Lập trình sáng tạo creative computing textbook mastercode.vnMasterCode.vn
 
Pd fbuoi7 8--tongquanseo-mastercode.vn
Pd fbuoi7 8--tongquanseo-mastercode.vnPd fbuoi7 8--tongquanseo-mastercode.vn
Pd fbuoi7 8--tongquanseo-mastercode.vnMasterCode.vn
 
Pd fbuoi5 6-ảnh hưởng của social media tới kết quả seo-mastercode.vn
Pd fbuoi5 6-ảnh hưởng của social media tới kết quả seo-mastercode.vnPd fbuoi5 6-ảnh hưởng của social media tới kết quả seo-mastercode.vn
Pd fbuoi5 6-ảnh hưởng của social media tới kết quả seo-mastercode.vnMasterCode.vn
 
Pdf buoi3 4-link-building-tran-ngoc-chinh-mastercode.vn
Pdf buoi3 4-link-building-tran-ngoc-chinh-mastercode.vnPdf buoi3 4-link-building-tran-ngoc-chinh-mastercode.vn
Pdf buoi3 4-link-building-tran-ngoc-chinh-mastercode.vnMasterCode.vn
 
Pd fbuoi3 4-kỹ thuật xây dựng back link-mastercode.vn
Pd fbuoi3 4-kỹ thuật xây dựng back link-mastercode.vnPd fbuoi3 4-kỹ thuật xây dựng back link-mastercode.vn
Pd fbuoi3 4-kỹ thuật xây dựng back link-mastercode.vnMasterCode.vn
 
Pd fbuoi2 onpage – tối ưu hóa trang web-mastercode.vn
Pd fbuoi2 onpage – tối ưu hóa trang web-mastercode.vnPd fbuoi2 onpage – tối ưu hóa trang web-mastercode.vn
Pd fbuoi2 onpage – tối ưu hóa trang web-mastercode.vnMasterCode.vn
 
Pd fbuoi1 giới thiệu seo tools cơ bản-seo manager + seo guy-mastercode.vn
Pd fbuoi1 giới thiệu seo tools cơ bản-seo manager + seo guy-mastercode.vnPd fbuoi1 giới thiệu seo tools cơ bản-seo manager + seo guy-mastercode.vn
Pd fbuoi1 giới thiệu seo tools cơ bản-seo manager + seo guy-mastercode.vnMasterCode.vn
 
Pdf buoi1 2-on-page-tran-ngoc-chinh-mastercode.vn
Pdf buoi1 2-on-page-tran-ngoc-chinh-mastercode.vnPdf buoi1 2-on-page-tran-ngoc-chinh-mastercode.vn
Pdf buoi1 2-on-page-tran-ngoc-chinh-mastercode.vnMasterCode.vn
 
Pdfbài 7 máy tính xác tay và máy in bảo trì sự cố máy tính-mastercode.vn
Pdfbài 7 máy tính xác tay và máy in   bảo trì sự cố máy tính-mastercode.vnPdfbài 7 máy tính xác tay và máy in   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 7 máy tính xác tay và máy in bảo trì sự cố máy tính-mastercode.vnMasterCode.vn
 
Pdfbài 6 bảo trì máy tính bảo trì sự cố máy tính-mastercode.vn
Pdfbài 6 bảo trì máy tính   bảo trì sự cố máy tính-mastercode.vnPdfbài 6 bảo trì máy tính   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 6 bảo trì máy tính bảo trì sự cố máy tính-mastercode.vnMasterCode.vn
 
Pdfbài 5 bảo trì và tối ưu windows bảo trì sự cố máy tính-mastercode.vn
Pdfbài 5 bảo trì và tối ưu windows   bảo trì sự cố máy tính-mastercode.vnPdfbài 5 bảo trì và tối ưu windows   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 5 bảo trì và tối ưu windows bảo trì sự cố máy tính-mastercode.vnMasterCode.vn
 
Pdfbài 4 ổ cứng hard drive bảo trì sự cố máy tính-mastercode.vn
Pdfbài 4 ổ cứng hard drive   bảo trì sự cố máy tính-mastercode.vnPdfbài 4 ổ cứng hard drive   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 4 ổ cứng hard drive bảo trì sự cố máy tính-mastercode.vnMasterCode.vn
 
Pdfbài 3 cpu và ram bảo trì sự cố máy tính-mastercode.vn
Pdfbài 3 cpu và ram   bảo trì sự cố máy tính-mastercode.vnPdfbài 3 cpu và ram   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 3 cpu và ram bảo trì sự cố máy tính-mastercode.vnMasterCode.vn
 
Pdfbài 1 giới thiệu chung về phần cứng bảo trì sự cố máy tính-mastercode.vn
Pdfbài 1 giới thiệu chung về phần cứng   bảo trì sự cố máy tính-mastercode.vnPdfbài 1 giới thiệu chung về phần cứng   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 1 giới thiệu chung về phần cứng bảo trì sự cố máy tính-mastercode.vnMasterCode.vn
 
Pdfbài 2 bo mạch chủ (main) bảo trì sự cố máy tính-mastercode.vn
Pdfbài 2 bo mạch chủ (main)   bảo trì sự cố máy tính-mastercode.vnPdfbài 2 bo mạch chủ (main)   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 2 bo mạch chủ (main) bảo trì sự cố máy tính-mastercode.vnMasterCode.vn
 

Más de MasterCode.vn (20)

Pd ftai lieu-tieng-anh-cho-nguoi-moi-bat-dau-mastercode.vn
Pd ftai lieu-tieng-anh-cho-nguoi-moi-bat-dau-mastercode.vnPd ftai lieu-tieng-anh-cho-nguoi-moi-bat-dau-mastercode.vn
Pd ftai lieu-tieng-anh-cho-nguoi-moi-bat-dau-mastercode.vn
 
Why apps-succeed-wpr-mastercode.vn
Why apps-succeed-wpr-mastercode.vnWhy apps-succeed-wpr-mastercode.vn
Why apps-succeed-wpr-mastercode.vn
 
Dzone performancemonitoring2016-mastercode.vn
Dzone performancemonitoring2016-mastercode.vnDzone performancemonitoring2016-mastercode.vn
Dzone performancemonitoring2016-mastercode.vn
 
Google công bố thông tin lịch xu hướng ngành 2017 mastercode.vn
Google công bố thông tin lịch xu hướng ngành 2017 mastercode.vnGoogle công bố thông tin lịch xu hướng ngành 2017 mastercode.vn
Google công bố thông tin lịch xu hướng ngành 2017 mastercode.vn
 
Nghiên cứu về khách hàng mastercode.vn
Nghiên cứu về khách hàng mastercode.vnNghiên cứu về khách hàng mastercode.vn
Nghiên cứu về khách hàng mastercode.vn
 
Lập trình sáng tạo creative computing textbook mastercode.vn
Lập trình sáng tạo creative computing textbook mastercode.vnLập trình sáng tạo creative computing textbook mastercode.vn
Lập trình sáng tạo creative computing textbook mastercode.vn
 
Pd fbuoi7 8--tongquanseo-mastercode.vn
Pd fbuoi7 8--tongquanseo-mastercode.vnPd fbuoi7 8--tongquanseo-mastercode.vn
Pd fbuoi7 8--tongquanseo-mastercode.vn
 
Pd fbuoi5 6-ảnh hưởng của social media tới kết quả seo-mastercode.vn
Pd fbuoi5 6-ảnh hưởng của social media tới kết quả seo-mastercode.vnPd fbuoi5 6-ảnh hưởng của social media tới kết quả seo-mastercode.vn
Pd fbuoi5 6-ảnh hưởng của social media tới kết quả seo-mastercode.vn
 
Pdf buoi3 4-link-building-tran-ngoc-chinh-mastercode.vn
Pdf buoi3 4-link-building-tran-ngoc-chinh-mastercode.vnPdf buoi3 4-link-building-tran-ngoc-chinh-mastercode.vn
Pdf buoi3 4-link-building-tran-ngoc-chinh-mastercode.vn
 
Pd fbuoi3 4-kỹ thuật xây dựng back link-mastercode.vn
Pd fbuoi3 4-kỹ thuật xây dựng back link-mastercode.vnPd fbuoi3 4-kỹ thuật xây dựng back link-mastercode.vn
Pd fbuoi3 4-kỹ thuật xây dựng back link-mastercode.vn
 
Pd fbuoi2 onpage – tối ưu hóa trang web-mastercode.vn
Pd fbuoi2 onpage – tối ưu hóa trang web-mastercode.vnPd fbuoi2 onpage – tối ưu hóa trang web-mastercode.vn
Pd fbuoi2 onpage – tối ưu hóa trang web-mastercode.vn
 
Pd fbuoi1 giới thiệu seo tools cơ bản-seo manager + seo guy-mastercode.vn
Pd fbuoi1 giới thiệu seo tools cơ bản-seo manager + seo guy-mastercode.vnPd fbuoi1 giới thiệu seo tools cơ bản-seo manager + seo guy-mastercode.vn
Pd fbuoi1 giới thiệu seo tools cơ bản-seo manager + seo guy-mastercode.vn
 
Pdf buoi1 2-on-page-tran-ngoc-chinh-mastercode.vn
Pdf buoi1 2-on-page-tran-ngoc-chinh-mastercode.vnPdf buoi1 2-on-page-tran-ngoc-chinh-mastercode.vn
Pdf buoi1 2-on-page-tran-ngoc-chinh-mastercode.vn
 
Pdfbài 7 máy tính xác tay và máy in bảo trì sự cố máy tính-mastercode.vn
Pdfbài 7 máy tính xác tay và máy in   bảo trì sự cố máy tính-mastercode.vnPdfbài 7 máy tính xác tay và máy in   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 7 máy tính xác tay và máy in bảo trì sự cố máy tính-mastercode.vn
 
Pdfbài 6 bảo trì máy tính bảo trì sự cố máy tính-mastercode.vn
Pdfbài 6 bảo trì máy tính   bảo trì sự cố máy tính-mastercode.vnPdfbài 6 bảo trì máy tính   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 6 bảo trì máy tính bảo trì sự cố máy tính-mastercode.vn
 
Pdfbài 5 bảo trì và tối ưu windows bảo trì sự cố máy tính-mastercode.vn
Pdfbài 5 bảo trì và tối ưu windows   bảo trì sự cố máy tính-mastercode.vnPdfbài 5 bảo trì và tối ưu windows   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 5 bảo trì và tối ưu windows bảo trì sự cố máy tính-mastercode.vn
 
Pdfbài 4 ổ cứng hard drive bảo trì sự cố máy tính-mastercode.vn
Pdfbài 4 ổ cứng hard drive   bảo trì sự cố máy tính-mastercode.vnPdfbài 4 ổ cứng hard drive   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 4 ổ cứng hard drive bảo trì sự cố máy tính-mastercode.vn
 
Pdfbài 3 cpu và ram bảo trì sự cố máy tính-mastercode.vn
Pdfbài 3 cpu và ram   bảo trì sự cố máy tính-mastercode.vnPdfbài 3 cpu và ram   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 3 cpu và ram bảo trì sự cố máy tính-mastercode.vn
 
Pdfbài 1 giới thiệu chung về phần cứng bảo trì sự cố máy tính-mastercode.vn
Pdfbài 1 giới thiệu chung về phần cứng   bảo trì sự cố máy tính-mastercode.vnPdfbài 1 giới thiệu chung về phần cứng   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 1 giới thiệu chung về phần cứng bảo trì sự cố máy tính-mastercode.vn
 
Pdfbài 2 bo mạch chủ (main) bảo trì sự cố máy tính-mastercode.vn
Pdfbài 2 bo mạch chủ (main)   bảo trì sự cố máy tính-mastercode.vnPdfbài 2 bo mạch chủ (main)   bảo trì sự cố máy tính-mastercode.vn
Pdfbài 2 bo mạch chủ (main) bảo trì sự cố máy tính-mastercode.vn
 

Último

QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 

Último (20)

QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 

Session 9 : intro to custom tags-classic tag - Giáo trình Bách Khoa Aptech

  • 1. Slide 1 of 29 Introduction to Custom Tags Classic tag
  • 2. Slide 2 of 29 Overview  Custom Tags  Various type of Custom Tags  Components of Tag Library  javax.servlet.jsp.tagext package  Common methods of Custom Tags
  • 3. Slide 3 of 29 Custom Tags  Allow Java programmer to embed Java codes in JSP documents  Provide a mechanism to reuse and encapsulate complex recurring code or tasks in JSP  Provide simplicity and reusability of Java code  Structure of custom tags in JSP is similar to XML tags
  • 4. Slide 4 of 29 Various Types of Custom Tag  Empty tags <td:welcome />  Tags with attributes <td: welcome color=”blue”></td:welcome>  Tags with a body <td: welcome> <%=today_date%> </td:welcome>  Nested tags <td1:ifTag condition “<%=eval>“ > <td2:valueTrue>The expression evaluates to true
  • 5. Slide 5 of 29 Component of Tag Library  Tag Handler  Tag Library Descriptor [TLD]  Tag File
  • 6. Slide 6 of 29 Mechanisms for building custom tags  Tag Handler  Tag files
  • 7. Slide 7 of 29 Mechanisms for building custom tags  Tag Handler – Classic Tag – Simple Tag
  • 8. Slide 8 of 29 Classic Tag
  • 9. Slide 9 of 29 javax.servlet.jsp.tagext package – Classic Custom Tag Classic tags is a JSP 1.2 technology. The classic tag handler class can be created by extending implementing . • Tag • IterationTag • BodyTag • TagSupport • BodyTagSupport
  • 10. Slide 10 of 29 tagext package  Tag - Interface – Is the base tag handler interface that defines the methods required by all tag handlers • public int doStartTag() throws JspException • public int doEndTag() throws JspException • public void release()  IterationTag - Interface – Used when a custom tag needs to repeatedly re-evaluate its body – Useful for looping through a collection of Objects without using a scriptlet • public int doAfterBody() throws JspException
  • 11. Slide 11 of 29 tagext package  BodyTag - Interface – Provide features for manipulating the body content • public void doInitBody() throws JspException • public void setBodyContent(BodyContent b)  BodyContent - Class – Is a subclass of the JSPWriter class – represents the body content of a tag  TagSupport - Class – Implements the Tag and IterationTag Interfaces. – Supports tag and a tag with body iterations
  • 12. Slide 12 of 29 tagext package  BodyTagSupport - Class – Sub class of TagSupport & implements BodyTag – used to develop custom tags with body
  • 13. Slide 13 of 29 Tag Library Descriptor [TLD]  Is an xml file that contains the tag library description  Contains the list and description of all custom tags in the library  Provides the JSP engine with meta-information about the custom tag and about its implementation  Components of the TLD classified into two groups <taglib> </taglib> <tag> </tag>
  • 14. Slide 14 of 29 Structure of TLD file <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd"> <taglib> <tlibversion>1.0</tlibversion> <jspversion>1.1</jspversion> <shortname>first</shortname> <info>Example of a tag</info> <tag> <name>welcome</name> <tagclass>TestTag</tagclass> <bodycontent>JSP</bodycontent> <info>An example</info> </tag> </taglib>
  • 15. Slide 15 of 29 Execution of JSP with Custom Tags Execution Cycle of a JSP file with Custom Tags
  • 16. Slide 16 of 29 Deploying and Using Custom Tags  Create a Tag Library Descriptor (.tld) file in the tlds folder inside WEB-INF  Create a Tag Handler class in proper package with tld file.  Include taglib directive in target JSP page  Use the custom tag
  • 17. Slide 17 of 29 tagext package  Returns value of doStartTag() – SKIP_BODY – EVAL_BODY_INCLUDE – EVAL_BODY_BUFFERED  Return value of doEndTag() – SKIP_PAGE – EVAL_PAGE  Return value of doAfterBody() – SKIP_BODY – EVAL_BODY_AGAIN
  • 18. Slide 18 of 29 Tag Life Cycle Instantiate Tag Handler doStartTag() doEndTag() return value setBodyContent() doInitBody() doAfterBody() return value Evaluate Body return value Evaluate rest of the Page Return from current page EVAL_BODY_BUFFERED EVAL_BODY_INCLUD E SKIP_BODY SKIP_BODY EVAL_BODY_AGAIN SKIP_PAGE EVAL_PAGE
  • 19. Slide 19 of 29 Summary  Custom Tags  Various type of Custom Tags  Components of Tag Library  javax.servlet.jsp.tagext package  Common methods of Custom Tags  Tag life cycle  Tag Library Descriptor  Execution of JSP with Custom Tags  Deploying and Using Custom Tags