SlideShare a Scribd company logo
1 of 21
Slide 1 of 21
JSP Standard Tag Library
Slide 2 of 21
Overview
 JSTL
 Core Tag Library
 Methods using EL
 I18N & Formatting Tag Library
 SQL Tag Library
 XML Tag Library
Slide 3 of 21
JSTL
 Custom tags provide a way to reuse
valuable components
 JSTL has reusable standard set of tags.
 Provides the user with a script-free
environment
 User can write code using tags instead of
Java code and scriptlets
 JSTL tags are easier for non-programmers
and inexperienced programmers
Slide 4 of 21
JSTL - Types
JSP Standard Tag Library
(JSTL)
Core Tag
Library
I18N &
Formatting
Tag Library
SQL Tag
Library
XML Tag
Library
Slide 5 of 21
Core Tag Library
Core Tag Library
General
Purpose Tags
Decision
Making Tags
Iteration Tags
set remove out forEach forTokensif choose
Slide 6 of 21
General-purpose tags
 <%@ taglib uri =
"http://java.sun.com/jsp/jstl/core" prefix =
"c" %>
– <c:set var=“varName” value=“value”
scope=“page|request|session|application” />
– <c:remove var=“varName” scope=“page|
request|session|application” />
– <c:out value=“value|expression”
escapeXml=“true|false”
default=“defaultValue” />
Slide 7 of 21
General-purpose tags-Example
Slide 8 of 21
Decision-making tags
– <c:if test =“testcondition” var=“varName”
scope=“page | request | session |
application”>
Body content
– </c:if>
– <c:choose>
<c:when test=“testCondition”>
Body Content
</c:when>
<c:otherwise>
Body Content
Slide 9 of 21
if tags
Slide 10 of 21
choose tags
Slide 11 of 21
Iteration tags
– <c:forEach var=“varName” item=“collection”
begin=“begin” end=“end” step=“step”>
Body Content
– </c:forEach>
– <c:forTokens items=“stringofToken”
delims=“delimiters” var=“varName” >
Body Content
– </c:forTokens>
Slide 12 of 21
Iteration tags - Example
Slide 13 of 21
SQL Tag Library
SQL Tag Library
setDataSource query update paramtransaction
Slide 14 of 21
SQL Tag Library – setDataSource tag
 <%@ taglib uri = "http://java.sun.com/jsp/jstl/sql" prefix
= “sql" %>
– <sql:setDataSource dataSource=“datasource” |
url=“jdbcurl” driver=“jdbcclassdriver” user=“username”
password=“password” var=“varName” scope=“page |
request | session | application” />
Slide 15 of 21
SQL Tag Library – query tag
– <sql:query var=“varName” dataSource=“datasource”
scope=“page | request | session | application”>
SQL Statement
Slide 16 of 21
SQL Tag Library – update tag
– <sql:update var=“varName” dataSource=“datasource”
scope=“page | request | session | application”>
SQL Statement
• <sql:param value=“value” />
– </sql:update>
Slide 17 of 21
SQL Tag Library – transaction tag
– <sql:transaction dataSource=“datasource”
isolation=“isolationLevel”>
• <sql:update> or <sql:query> Statements
– </sql:transaction>
Slide 18 of 21
SQL Tag Library – transaction tag
Slide 19 of 21
param Tag
 Param is used to set values for parameters
markers (“?”) in SQL statement
 It acts as a sub tag for <sql:query> and
<sql:update>
Slide 20 of 21
Summary
 JSTL
 Core Tag Library
– General purpose Tags
– Decision making Tags
– Iteration Tags
Slide 21 of 21
Summary
 Methods using EL
 I18N & Formatting Tag Library
– Locale, Bundle, Message
– formatDate, formatNumber
 SQL Tag Library
– setDataSource
– query
– update
– transaction
– param

More Related Content

Similar to Session 7 : jstl - Giáo trình Bách Khoa Aptech

Introduction to JSP
Introduction to JSPIntroduction to JSP
Introduction to JSP
Geethu Mohan
 

Similar to Session 7 : jstl - Giáo trình Bách Khoa Aptech (20)

Java Web Programming [5/9] : EL, JSTL and Custom Tags
Java Web Programming [5/9] : EL, JSTL and Custom TagsJava Web Programming [5/9] : EL, JSTL and Custom Tags
Java Web Programming [5/9] : EL, JSTL and Custom Tags
 
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
 
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 ...
 
Advance java session 16
Advance java session 16Advance java session 16
Advance java session 16
 
Lecture 5 JSTL, custom tags, maven
Lecture 5   JSTL, custom tags, mavenLecture 5   JSTL, custom tags, maven
Lecture 5 JSTL, custom tags, maven
 
Scala active record
Scala active recordScala active record
Scala active record
 
Java Web Development with Stripes
Java Web Development with StripesJava Web Development with Stripes
Java Web Development with Stripes
 
Lap trinh web [Slide jsp]
Lap trinh web [Slide jsp]Lap trinh web [Slide jsp]
Lap trinh web [Slide jsp]
 
JSP Technology II
JSP Technology IIJSP Technology II
JSP Technology II
 
Jsp and jstl
Jsp and jstlJsp and jstl
Jsp and jstl
 
Jsp standard tag_library
Jsp standard tag_libraryJsp standard tag_library
Jsp standard tag_library
 
Introduction to JSP
Introduction to JSPIntroduction to JSP
Introduction to JSP
 
Spring data requery
Spring data requerySpring data requery
Spring data requery
 
Advance java session 5
Advance java session 5Advance java session 5
Advance java session 5
 
Java .ppt
Java .pptJava .ppt
Java .ppt
 
25.ppt
25.ppt25.ppt
25.ppt
 
Jstl
JstlJstl
Jstl
 
A Practical Enterprise Feature Store on Delta Lake
A Practical Enterprise Feature Store on Delta LakeA Practical Enterprise Feature Store on Delta Lake
A Practical Enterprise Feature Store on Delta Lake
 
JSTL.pptx
JSTL.pptxJSTL.pptx
JSTL.pptx
 
Session_15_JSTL.pdf
Session_15_JSTL.pdfSession_15_JSTL.pdf
Session_15_JSTL.pdf
 

More from 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
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
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
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
MasterCode.vn
 

More from 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
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 

Session 7 : jstl - Giáo trình Bách Khoa Aptech

  • 1. Slide 1 of 21 JSP Standard Tag Library
  • 2. Slide 2 of 21 Overview  JSTL  Core Tag Library  Methods using EL  I18N & Formatting Tag Library  SQL Tag Library  XML Tag Library
  • 3. Slide 3 of 21 JSTL  Custom tags provide a way to reuse valuable components  JSTL has reusable standard set of tags.  Provides the user with a script-free environment  User can write code using tags instead of Java code and scriptlets  JSTL tags are easier for non-programmers and inexperienced programmers
  • 4. Slide 4 of 21 JSTL - Types JSP Standard Tag Library (JSTL) Core Tag Library I18N & Formatting Tag Library SQL Tag Library XML Tag Library
  • 5. Slide 5 of 21 Core Tag Library Core Tag Library General Purpose Tags Decision Making Tags Iteration Tags set remove out forEach forTokensif choose
  • 6. Slide 6 of 21 General-purpose tags  <%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %> – <c:set var=“varName” value=“value” scope=“page|request|session|application” /> – <c:remove var=“varName” scope=“page| request|session|application” /> – <c:out value=“value|expression” escapeXml=“true|false” default=“defaultValue” />
  • 7. Slide 7 of 21 General-purpose tags-Example
  • 8. Slide 8 of 21 Decision-making tags – <c:if test =“testcondition” var=“varName” scope=“page | request | session | application”> Body content – </c:if> – <c:choose> <c:when test=“testCondition”> Body Content </c:when> <c:otherwise> Body Content
  • 9. Slide 9 of 21 if tags
  • 10. Slide 10 of 21 choose tags
  • 11. Slide 11 of 21 Iteration tags – <c:forEach var=“varName” item=“collection” begin=“begin” end=“end” step=“step”> Body Content – </c:forEach> – <c:forTokens items=“stringofToken” delims=“delimiters” var=“varName” > Body Content – </c:forTokens>
  • 12. Slide 12 of 21 Iteration tags - Example
  • 13. Slide 13 of 21 SQL Tag Library SQL Tag Library setDataSource query update paramtransaction
  • 14. Slide 14 of 21 SQL Tag Library – setDataSource tag  <%@ taglib uri = "http://java.sun.com/jsp/jstl/sql" prefix = “sql" %> – <sql:setDataSource dataSource=“datasource” | url=“jdbcurl” driver=“jdbcclassdriver” user=“username” password=“password” var=“varName” scope=“page | request | session | application” />
  • 15. Slide 15 of 21 SQL Tag Library – query tag – <sql:query var=“varName” dataSource=“datasource” scope=“page | request | session | application”> SQL Statement
  • 16. Slide 16 of 21 SQL Tag Library – update tag – <sql:update var=“varName” dataSource=“datasource” scope=“page | request | session | application”> SQL Statement • <sql:param value=“value” /> – </sql:update>
  • 17. Slide 17 of 21 SQL Tag Library – transaction tag – <sql:transaction dataSource=“datasource” isolation=“isolationLevel”> • <sql:update> or <sql:query> Statements – </sql:transaction>
  • 18. Slide 18 of 21 SQL Tag Library – transaction tag
  • 19. Slide 19 of 21 param Tag  Param is used to set values for parameters markers (“?”) in SQL statement  It acts as a sub tag for <sql:query> and <sql:update>
  • 20. Slide 20 of 21 Summary  JSTL  Core Tag Library – General purpose Tags – Decision making Tags – Iteration Tags
  • 21. Slide 21 of 21 Summary  Methods using EL  I18N & Formatting Tag Library – Locale, Bundle, Message – formatDate, formatNumber  SQL Tag Library – setDataSource – query – update – transaction – param