SlideShare a Scribd company logo
JSP Standard Tag Library(JSTL)
JSP Standard Tag Library
• Introduction to JSTL
• Exploring the features of JSTL
• Working with core Tag Library
• Working with SQL Tag library
Introduction to JSTL
•Contains Standard tag library
•Library is available in all compliant containers
•Wide range of custom action functionality
•Readability and Maintainability
Function Overview of JSTL
•Core functionality
•XML Manipulation
•SQL
•Internationalization and Formatting
•Note
•Makes use of expression language
JSTL expression language
• Accessed via ${expression}
• Provides shorthand notation to access
- Attributes of standard servlet Objects
- Bean properties
- Map,List and Array Element
• Standard part of JSP 2.0
- In JSTL EL can be used only in attributes
- In JSP 2.0 EL can ne used anywheres
Logic tags
• One choice: if
<c:if test="${someTest}“>Content
</c:if>
• Lots of choices: choose
<c:choose>
<c:when test="test1">Content1</c:when>
<c:when test="test2">Content2</c:when>
<c:when test="testN">ContentN</c:when>
<c:otherwise>Default Content</c:otherwise>
</c:choose>
Caution: resist use of business logic!
The “if” tag
<%@ taglib prefix="c” uri="http://java.sun.com/jstl/core" %>
<UL>
<c:forEach var="i" begin="1" end="10">
<LI><c:out value="${i}"/>
<c:if test="${i > 7}">
(greater than 7)
</c:if>
</c:forEach>
</UL>
“Choose” tag
<%@ taglib prefix="c” uri="http://java.sun.com/jstl/core" %>
<UL>
<c:forEach var="i" begin="1" end="10">
<LI><c:out value="${i}"/>
<c:choose><c:when test="${i < 4}">
(small)
</c:when><c:when test="${i < 8}">
(medium)
</c:when>
<c:otherwise>
(large)
</c:otherwise>
</c:choose>
</c:forEach></UL>
Database Access Tag
• <sql:setDataSource>
- Specifies data source (can also be set by config
settings)
• <sql:query>
- Queries database and stores ResultSet in variable
- Warning: this usage violates rule of keeping
business logic out of presentation layer. Instead, do
database access in servlet and pass results to JSP
via MVC.
Database Access Tag
• <sql:update>
• <sql:param>
• <sql:dateParam>
• <sql:transaction>
- Performs the enclosed <sql:query> and
<sql:update>actions as a single transaction
sql:setDataSource
• You can set a data source globally via configuration settings or
application-scoped variables.
Preferred approach in real applications
Or, you can set it on a specific page
<%@ taglib prefix="sql” uri="http://java.sun.com/jstl/sql" %>
<sql:setDataSource driver=“com.mysql.jdbc.Driver"
url=“jdbc:mysql://localhost:3306/test” user=“root"
password=“root"/>
sql:query
• Form 1: use the sql attribute
- <sql:query var="results" sql="SELECT *
FROM …"/>
• Form 2: put the query in the body of the tag
- <sql:query var="results“>
- SELECT * FROM …
- </sql:query>
sql:query
• Options
- dataSource
- maxRows
- startRow
• Caution
- Embedding SQL directly in JSP may be hard to
maintain
Simple Example
<%@ taglib prefix="c"
uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="sql"
uri="http://java.sun.com/jstl/sql" %>
<sql:setDataSource
driver=“com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/test"
user=“root"
password=“root"/>
Simple Example Continued
<sql:query var="employees">
SELECT * FROM employees
</sql:query>
<UL>
<c:forEach var="row" items="${employees.rows}">
<LI><c:out value="${row.firstname}"/>
<c:out value="${row.lastname}"/>
</c:forEach>
</UL>
URL-Handling Tags
• <c:import>
- Read content from arbitrary URLs
• Insert into page
• Store in variable
• Or make accessible via a reader
- Unlike <jsp:include>, not restricted to own system
• <c:redirect>
- Redirects response to specified URL
• <c:param>
- Encodes a request parameter and adds it to a URL
- May be used within body of <c:import> or <c:redirect>
Summary
• JSTL is similar to the old Struts looping and logic tags
• JSTL is standardized, but not a standard part of JSP 1.2 or 2.0
- It must be downloaded and installed separately
• Supports a concise expression language
- Lets you access bean properties and implicit objects
- EL is standard part of JSP 2.0
• Looping tags
- Explicit numeric values
- Arrays, collections, maps, strings, etc.
• Conditional evaluation tags
- Single options
- Multiple options

More Related Content

What's hot (20)

Running ms sql stored procedures in mule
Running ms sql stored procedures in muleRunning ms sql stored procedures in mule
Running ms sql stored procedures in mule
AnilKumar Etagowni
 
Jdbc Java Programming
Jdbc Java ProgrammingJdbc Java Programming
Jdbc Java Programming
chhaichivon
 
Persitance Data with sqlite
Persitance Data with sqlitePersitance Data with sqlite
Persitance Data with sqlite
Arif Huda
 
JSP - Part 1
JSP - Part 1JSP - Part 1
JSP - Part 1
Hitesh-Java
 
Apache Con Us2007 Apachei Batis
Apache Con Us2007 Apachei BatisApache Con Us2007 Apachei Batis
Apache Con Us2007 Apachei Batis
day
 
Qure Tech Presentation
Qure Tech PresentationQure Tech Presentation
Qure Tech Presentation
sqlserver.co.il
 
Advance java session 10
Advance java session 10Advance java session 10
Advance java session 10
Smita B Kumar
 
Deploy and Manage the Infrastructure Using Azure Resource Manager
Deploy and Manage the Infrastructure Using Azure Resource ManagerDeploy and Manage the Infrastructure Using Azure Resource Manager
Deploy and Manage the Infrastructure Using Azure Resource Manager
GlobalLogic Ukraine
 
Html To JSP
Html To JSPHtml To JSP
Html To JSP
PlanetB4U
 
Jdbc
JdbcJdbc
Jdbc
lathasiva
 
servlets and jsp
servlets and jspservlets and jsp
servlets and jsp
sachin kumbhojkar
 
Sql lite android
Sql lite androidSql lite android
Sql lite android
Dushyant Nasit
 
Backbonejs for beginners
Backbonejs for beginnersBackbonejs for beginners
Backbonejs for beginners
Divakar Gu
 
Persistence with Ada Database Objects (ADO)
Persistence with Ada Database Objects (ADO)Persistence with Ada Database Objects (ADO)
Persistence with Ada Database Objects (ADO)
Stephane Carrez
 
Persistences
PersistencesPersistences
Persistences
Training Guide
 
Java >= 9
Java >= 9Java >= 9
Java >= 9
Benjamin Pack
 
Grails Controllers
Grails ControllersGrails Controllers
Grails Controllers
NexThoughts Technologies
 
Liquidating database frustrations with liquibase
Liquidating database frustrations with liquibaseLiquidating database frustrations with liquibase
Liquidating database frustrations with liquibase
Paul Churchward
 
Rails application refactoring steps
Rails application refactoring stepsRails application refactoring steps
Rails application refactoring steps
Masud Rana
 
XSLT presentation
XSLT presentationXSLT presentation
XSLT presentation
Miguel Angel Teheran Garcia
 
Running ms sql stored procedures in mule
Running ms sql stored procedures in muleRunning ms sql stored procedures in mule
Running ms sql stored procedures in mule
AnilKumar Etagowni
 
Jdbc Java Programming
Jdbc Java ProgrammingJdbc Java Programming
Jdbc Java Programming
chhaichivon
 
Persitance Data with sqlite
Persitance Data with sqlitePersitance Data with sqlite
Persitance Data with sqlite
Arif Huda
 
Apache Con Us2007 Apachei Batis
Apache Con Us2007 Apachei BatisApache Con Us2007 Apachei Batis
Apache Con Us2007 Apachei Batis
day
 
Advance java session 10
Advance java session 10Advance java session 10
Advance java session 10
Smita B Kumar
 
Deploy and Manage the Infrastructure Using Azure Resource Manager
Deploy and Manage the Infrastructure Using Azure Resource ManagerDeploy and Manage the Infrastructure Using Azure Resource Manager
Deploy and Manage the Infrastructure Using Azure Resource Manager
GlobalLogic Ukraine
 
Backbonejs for beginners
Backbonejs for beginnersBackbonejs for beginners
Backbonejs for beginners
Divakar Gu
 
Persistence with Ada Database Objects (ADO)
Persistence with Ada Database Objects (ADO)Persistence with Ada Database Objects (ADO)
Persistence with Ada Database Objects (ADO)
Stephane Carrez
 
Liquidating database frustrations with liquibase
Liquidating database frustrations with liquibaseLiquidating database frustrations with liquibase
Liquidating database frustrations with liquibase
Paul Churchward
 
Rails application refactoring steps
Rails application refactoring stepsRails application refactoring steps
Rails application refactoring steps
Masud Rana
 

Similar to Advance java session 16 (20)

Lecture 5 JSTL, custom tags, maven
Lecture 5   JSTL, custom tags, mavenLecture 5   JSTL, custom tags, maven
Lecture 5 JSTL, custom tags, maven
Fahad Golra
 
10 jdbc
10 jdbc10 jdbc
10 jdbc
snopteck
 
Ch. 9 jsp standard tag library
Ch. 9 jsp standard tag libraryCh. 9 jsp standard tag library
Ch. 9 jsp standard tag library
Manolis Vavalis
 
Jdbc Best Practices - DB2/ IDUG - Orlando, May 10, 2004
Jdbc Best Practices - DB2/ IDUG - Orlando, May 10, 2004Jdbc Best Practices - DB2/ IDUG - Orlando, May 10, 2004
Jdbc Best Practices - DB2/ IDUG - Orlando, May 10, 2004
derek_clark_ashmore
 
13 java beans
13 java beans13 java beans
13 java beans
snopteck
 
Jsp
JspJsp
Jsp
Mumbai Academisc
 
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
Soujanya V
 
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Ayes Chinmay
 
15 expression-language
15 expression-language15 expression-language
15 expression-language
snopteck
 
Java .ppt
Java .pptJava .ppt
Java .ppt
MuhammedYaseenMc
 
25.ppt
25.ppt25.ppt
25.ppt
veningstonk
 
azuretip1detailshereforlearninganddoingpractice
azuretip1detailshereforlearninganddoingpracticeazuretip1detailshereforlearninganddoingpractice
azuretip1detailshereforlearninganddoingpractice
Avinashk515020
 
Jstl
JstlJstl
Jstl
vishal choudhary
 
Ajax Tags Advanced
Ajax Tags AdvancedAjax Tags Advanced
Ajax Tags Advanced
AkramWaseem
 
JSTL.pptx
JSTL.pptxJSTL.pptx
JSTL.pptx
SPAMVEDANT
 
14 mvc
14 mvc14 mvc
14 mvc
snopteck
 
JSP Part 2
JSP Part 2JSP Part 2
JSP Part 2
DeeptiJava
 
Iasi code camp 12 october 2013 jax-rs-jee-ecosystem - catalin mihalache
Iasi code camp 12 october 2013   jax-rs-jee-ecosystem - catalin mihalacheIasi code camp 12 october 2013   jax-rs-jee-ecosystem - catalin mihalache
Iasi code camp 12 october 2013 jax-rs-jee-ecosystem - catalin mihalache
Codecamp Romania
 
Struts2-Spring=Hibernate
Struts2-Spring=HibernateStruts2-Spring=Hibernate
Struts2-Spring=Hibernate
Jay Shah
 
Jsp and jstl
Jsp and jstlJsp and jstl
Jsp and jstl
vishal choudhary
 
Lecture 5 JSTL, custom tags, maven
Lecture 5   JSTL, custom tags, mavenLecture 5   JSTL, custom tags, maven
Lecture 5 JSTL, custom tags, maven
Fahad Golra
 
Ch. 9 jsp standard tag library
Ch. 9 jsp standard tag libraryCh. 9 jsp standard tag library
Ch. 9 jsp standard tag library
Manolis Vavalis
 
Jdbc Best Practices - DB2/ IDUG - Orlando, May 10, 2004
Jdbc Best Practices - DB2/ IDUG - Orlando, May 10, 2004Jdbc Best Practices - DB2/ IDUG - Orlando, May 10, 2004
Jdbc Best Practices - DB2/ IDUG - Orlando, May 10, 2004
derek_clark_ashmore
 
13 java beans
13 java beans13 java beans
13 java beans
snopteck
 
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
Soujanya V
 
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Ayes Chinmay
 
15 expression-language
15 expression-language15 expression-language
15 expression-language
snopteck
 
azuretip1detailshereforlearninganddoingpractice
azuretip1detailshereforlearninganddoingpracticeazuretip1detailshereforlearninganddoingpractice
azuretip1detailshereforlearninganddoingpractice
Avinashk515020
 
Ajax Tags Advanced
Ajax Tags AdvancedAjax Tags Advanced
Ajax Tags Advanced
AkramWaseem
 
Iasi code camp 12 october 2013 jax-rs-jee-ecosystem - catalin mihalache
Iasi code camp 12 october 2013   jax-rs-jee-ecosystem - catalin mihalacheIasi code camp 12 october 2013   jax-rs-jee-ecosystem - catalin mihalache
Iasi code camp 12 october 2013 jax-rs-jee-ecosystem - catalin mihalache
Codecamp Romania
 
Struts2-Spring=Hibernate
Struts2-Spring=HibernateStruts2-Spring=Hibernate
Struts2-Spring=Hibernate
Jay Shah
 

More from Smita B Kumar (19)

Advance java session 20
Advance java session 20Advance java session 20
Advance java session 20
Smita B Kumar
 
Advance java session 19
Advance java session 19Advance java session 19
Advance java session 19
Smita B Kumar
 
Advance java session 18
Advance java session 18Advance java session 18
Advance java session 18
Smita B Kumar
 
Advance java session 17
Advance java session 17Advance java session 17
Advance java session 17
Smita B Kumar
 
Advance java session 15
Advance java session 15Advance java session 15
Advance java session 15
Smita B Kumar
 
Advance java session 14
Advance java session 14Advance java session 14
Advance java session 14
Smita B Kumar
 
Advance java session 13
Advance java session 13Advance java session 13
Advance java session 13
Smita B Kumar
 
Advance java session 12
Advance java session 12Advance java session 12
Advance java session 12
Smita B Kumar
 
Advance java session 11
Advance java session 11Advance java session 11
Advance java session 11
Smita B Kumar
 
Advance java session 9
Advance java session 9Advance java session 9
Advance java session 9
Smita B Kumar
 
Advance java session 8
Advance java session 8Advance java session 8
Advance java session 8
Smita B Kumar
 
Advance java session 7
Advance java session 7Advance java session 7
Advance java session 7
Smita B Kumar
 
Advance java session 6
Advance java session 6Advance java session 6
Advance java session 6
Smita B Kumar
 
Advance java session 5
Advance java session 5Advance java session 5
Advance java session 5
Smita B Kumar
 
Advance java session 4
Advance java session 4Advance java session 4
Advance java session 4
Smita B Kumar
 
Advance java session 3
Advance java session 3Advance java session 3
Advance java session 3
Smita B Kumar
 
Advance java session 2
Advance java session 2Advance java session 2
Advance java session 2
Smita B Kumar
 
JEE session 1
JEE session 1JEE session 1
JEE session 1
Smita B Kumar
 
01 introduction to struts2
01 introduction to struts201 introduction to struts2
01 introduction to struts2
Smita B Kumar
 
Advance java session 20
Advance java session 20Advance java session 20
Advance java session 20
Smita B Kumar
 
Advance java session 19
Advance java session 19Advance java session 19
Advance java session 19
Smita B Kumar
 
Advance java session 18
Advance java session 18Advance java session 18
Advance java session 18
Smita B Kumar
 
Advance java session 17
Advance java session 17Advance java session 17
Advance java session 17
Smita B Kumar
 
Advance java session 15
Advance java session 15Advance java session 15
Advance java session 15
Smita B Kumar
 
Advance java session 14
Advance java session 14Advance java session 14
Advance java session 14
Smita B Kumar
 
Advance java session 13
Advance java session 13Advance java session 13
Advance java session 13
Smita B Kumar
 
Advance java session 12
Advance java session 12Advance java session 12
Advance java session 12
Smita B Kumar
 
Advance java session 11
Advance java session 11Advance java session 11
Advance java session 11
Smita B Kumar
 
Advance java session 9
Advance java session 9Advance java session 9
Advance java session 9
Smita B Kumar
 
Advance java session 8
Advance java session 8Advance java session 8
Advance java session 8
Smita B Kumar
 
Advance java session 7
Advance java session 7Advance java session 7
Advance java session 7
Smita B Kumar
 
Advance java session 6
Advance java session 6Advance java session 6
Advance java session 6
Smita B Kumar
 
Advance java session 5
Advance java session 5Advance java session 5
Advance java session 5
Smita B Kumar
 
Advance java session 4
Advance java session 4Advance java session 4
Advance java session 4
Smita B Kumar
 
Advance java session 3
Advance java session 3Advance java session 3
Advance java session 3
Smita B Kumar
 
Advance java session 2
Advance java session 2Advance java session 2
Advance java session 2
Smita B Kumar
 
01 introduction to struts2
01 introduction to struts201 introduction to struts2
01 introduction to struts2
Smita B Kumar
 

Recently uploaded (20)

Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 

Advance java session 16

  • 1. JSP Standard Tag Library(JSTL)
  • 2. JSP Standard Tag Library • Introduction to JSTL • Exploring the features of JSTL • Working with core Tag Library • Working with SQL Tag library
  • 3. Introduction to JSTL •Contains Standard tag library •Library is available in all compliant containers •Wide range of custom action functionality •Readability and Maintainability
  • 4. Function Overview of JSTL •Core functionality •XML Manipulation •SQL •Internationalization and Formatting •Note •Makes use of expression language
  • 5. JSTL expression language • Accessed via ${expression} • Provides shorthand notation to access - Attributes of standard servlet Objects - Bean properties - Map,List and Array Element • Standard part of JSP 2.0 - In JSTL EL can be used only in attributes - In JSP 2.0 EL can ne used anywheres
  • 6. Logic tags • One choice: if <c:if test="${someTest}“>Content </c:if> • Lots of choices: choose <c:choose> <c:when test="test1">Content1</c:when> <c:when test="test2">Content2</c:when> <c:when test="testN">ContentN</c:when> <c:otherwise>Default Content</c:otherwise> </c:choose> Caution: resist use of business logic!
  • 7. The “if” tag <%@ taglib prefix="c” uri="http://java.sun.com/jstl/core" %> <UL> <c:forEach var="i" begin="1" end="10"> <LI><c:out value="${i}"/> <c:if test="${i > 7}"> (greater than 7) </c:if> </c:forEach> </UL>
  • 8. “Choose” tag <%@ taglib prefix="c” uri="http://java.sun.com/jstl/core" %> <UL> <c:forEach var="i" begin="1" end="10"> <LI><c:out value="${i}"/> <c:choose><c:when test="${i < 4}"> (small) </c:when><c:when test="${i < 8}"> (medium) </c:when> <c:otherwise> (large) </c:otherwise> </c:choose> </c:forEach></UL>
  • 9. Database Access Tag • <sql:setDataSource> - Specifies data source (can also be set by config settings) • <sql:query> - Queries database and stores ResultSet in variable - Warning: this usage violates rule of keeping business logic out of presentation layer. Instead, do database access in servlet and pass results to JSP via MVC.
  • 10. Database Access Tag • <sql:update> • <sql:param> • <sql:dateParam> • <sql:transaction> - Performs the enclosed <sql:query> and <sql:update>actions as a single transaction
  • 11. sql:setDataSource • You can set a data source globally via configuration settings or application-scoped variables. Preferred approach in real applications Or, you can set it on a specific page <%@ taglib prefix="sql” uri="http://java.sun.com/jstl/sql" %> <sql:setDataSource driver=“com.mysql.jdbc.Driver" url=“jdbc:mysql://localhost:3306/test” user=“root" password=“root"/>
  • 12. sql:query • Form 1: use the sql attribute - <sql:query var="results" sql="SELECT * FROM …"/> • Form 2: put the query in the body of the tag - <sql:query var="results“> - SELECT * FROM … - </sql:query>
  • 13. sql:query • Options - dataSource - maxRows - startRow • Caution - Embedding SQL directly in JSP may be hard to maintain
  • 14. Simple Example <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %> <sql:setDataSource driver=“com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/test" user=“root" password=“root"/>
  • 15. Simple Example Continued <sql:query var="employees"> SELECT * FROM employees </sql:query> <UL> <c:forEach var="row" items="${employees.rows}"> <LI><c:out value="${row.firstname}"/> <c:out value="${row.lastname}"/> </c:forEach> </UL>
  • 16. URL-Handling Tags • <c:import> - Read content from arbitrary URLs • Insert into page • Store in variable • Or make accessible via a reader - Unlike <jsp:include>, not restricted to own system • <c:redirect> - Redirects response to specified URL • <c:param> - Encodes a request parameter and adds it to a URL - May be used within body of <c:import> or <c:redirect>
  • 17. Summary • JSTL is similar to the old Struts looping and logic tags • JSTL is standardized, but not a standard part of JSP 1.2 or 2.0 - It must be downloaded and installed separately • Supports a concise expression language - Lets you access bean properties and implicit objects - EL is standard part of JSP 2.0 • Looping tags - Explicit numeric values - Arrays, collections, maps, strings, etc. • Conditional evaluation tags - Single options - Multiple options