SlideShare a Scribd company logo
COURSE:WEB TECHNOLOGIES
INTRODUCTION TO JSP,JSP LIFE
CYCLE, ANATOMY OF JSP PAGE
AND JSP PROCESSING
By
AAQIB HUSSAIN
MODULE-III
2
Course outcome / Topic learning outcome
Name of the Topic covered Topic Learning Outcome Course Outcome
Introduction to
JSP,Anatomy of JSP page
and JSP Processing
Understand and apply
the methods of servlet
for request - response
paradigm.
Develop a server side web
application using servlets
for request-response
programming paradigm
List the course outcome / Topic outcome
3
Outcome achieved
Name of the topic: Introduction to JSP,Anatomy of JSP page
and JSP Processing
Students will be able to do:
1 Design the dynamic web pages using HTML and JSP
2
JAVA SERVER PAGES
Introduction to JSP:
• Besides servlets there exists one more java based
technology called JSP(Java Server Pages) to develop
web applications.
• JSP was developed by Sun Micro Systems to allow
server side development.JSP is a kind of scripting
language in which we can embed java code along
with HTML elements.
• JSP is textual document that describes how to create
a response object from a request object of a given
JAVA SERVER PAGES
In the processing of JSP include:
• A JSP page defines JSP page implementation class
that implements the javax.servlet interface.
• At the request time ,the request is made to JSP page
which will be delivered to the JSP page
implementation object for processing.
• In any web application a program on server processes
request and generate response by using default HTTP
protocol.
JSP LIFE CYCLE
In the processing of JSP include:
• The web server needs a JSP engine, i.e, a container to
process JSP pages. It resides inside the webserver.The
JSP container is responsible for intercepting requests
for JSP pages.
Compilation process of JSP page involves three steps:
• Parsing of JSP
• Turning JSP into servlet
• Compiling the servlet
JSP LIFE CYCLE
1.Translation-
demo.jsp page
is translated in
to Servlet
2.Compilation-
Servlet
demo_jsp.java
is created
3.Class Loading-
demo_ jsp.java
is loaded in to
demo_jsp.class
6.Request Processing-
Servlet demo_jsp.java
is executed using
service method
5.Initiaization-
Servlet demo_ljsp
is initialized
4.Instantiation-
Servlet
demo_jsp is
instantiated
7.Destroy-
Servlet
demo_jsp is
destroyed
Anatomy of
JSP
A JSP page is a web page with JSP elements for generating the parts that
differ for each request.
Anatomy of JSP
• JSP page is a combination of JSP element and template text.
• Template text can be any text which includes HTML, WML, XML, or
even plain text. it can be used with any markup language.
• Template text is always passed directly to the browser.
• When a JSP page request is processed, the template text and
dynamic content generated by the JSP elements are merged, and the
result is sent as the response to the browser.
JSP Processing
• A web server needs a servlet container to provide an interface to
servlets, the server needs a JSP container to process JSP pages.
• The JSP container is responsible for intercepting requests for JSP
pages.
• To process all JSP elements in the page, the container first turns the
JSP page into a servlet (known as the JSP page implementationclass).
• The template text is converted to println( ) statements similar to the
ones in the hand-coded servlet and all JSP elements are converted to
Java code that implements the corresponding dynamic behavior. The
container then compiles the servlet class.
• Converting the JSP page to a servlet and compiling the servlet form
the translation phase.
• The JSP container initiates the translation phase for a page
automatically when it receives the first request for the page. Since
the translation phase takes a bit of time, the first user to request a
JSP page notices a slight delay.
• The translation phase can also be initiated explicitly and is referred to
as pre-compilation of a JSP page.
• Pre-compiling a JSP page is a way to avoid hitting the first user with
this delay.
• The JSP container is also responsible for invoking the JSP page
implementation class (the generated servlet) to process each request
and generate the response. This is called the request processing
phase.
The two phases are illustrated in the
figure
Anatomy of JSP
• JSP page is a combination of JSP element and template text.
• Template text can be any text which includes HTML, WML, XML, or
even plain text. it can be used with any markup language.
• Template text is always passed directly to the browser.
• When a JSP page request is processed, the template text and
dynamic content generated by the JSP elements are merged, and the
result is sent as the response to the browser.
• As long as the JSP page remains unchanged, any subsequent request
goes straight to the request processing phase (i.e., the container
simply executes the class file).
• When the JSP page is modified, it goes through the translation phase
again before entering the request processing phase.
• The JSP container is also responsible for invoking the JSP page
implementation class (the generated servlet) to process each request
and generate the response. This is called the request processing
phase.
JSP Declarations
• A JSP declaration declares one or more variables or methods that
one can use in Java code later in the JSP file.
• The JSP declaration tag is a piece of java code mainly used to declare
fields and methods
SYNTAX
<%! declaration; [ declaration; ]+ ... %>
Ad

More Related Content

What's hot (20)

Servlets
ServletsServlets
Servlets
ZainabNoorGul
 
Routing algorithm
Routing algorithmRouting algorithm
Routing algorithm
Bushra M
 
Applets in java
Applets in javaApplets in java
Applets in java
Wani Zahoor
 
Jsp lifecycle
Jsp   lifecycleJsp   lifecycle
Jsp lifecycle
chauhankapil
 
Java servlets and CGI
Java servlets and CGIJava servlets and CGI
Java servlets and CGI
lavanya marichamy
 
Event handling
Event handlingEvent handling
Event handling
swapnac12
 
Servlet and servlet life cycle
Servlet and servlet life cycleServlet and servlet life cycle
Servlet and servlet life cycle
Dhruvin Nakrani
 
Remote Method Invocation (RMI)
Remote Method Invocation (RMI)Remote Method Invocation (RMI)
Remote Method Invocation (RMI)
Peter R. Egli
 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
Vikas Jagtap
 
Get and post methods
Get and post methodsGet and post methods
Get and post methods
baabtra.com - No. 1 supplier of quality freshers
 
Agents in Artificial intelligence
Agents in Artificial intelligence Agents in Artificial intelligence
Agents in Artificial intelligence
Lalit Birla
 
HTTP request and response
HTTP request and responseHTTP request and response
HTTP request and response
Sahil Agarwal
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
Dattatray Gandhmal
 
Concurrency Control in Distributed Database.
Concurrency Control in Distributed Database.Concurrency Control in Distributed Database.
Concurrency Control in Distributed Database.
Meghaj Mallick
 
3. mining frequent patterns
3. mining frequent patterns3. mining frequent patterns
3. mining frequent patterns
Azad public school
 
Minmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slidesMinmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slides
SamiaAziz4
 
Tcpip services and applications
Tcpip services and applicationsTcpip services and applications
Tcpip services and applications
Online
 
Sessions and cookies
Sessions and cookiesSessions and cookies
Sessions and cookies
www.netgains.org
 
Introduction to ajax
Introduction  to  ajaxIntroduction  to  ajax
Introduction to ajax
Pihu Goel
 
Concept learning
Concept learningConcept learning
Concept learning
Musa Hawamdah
 
Routing algorithm
Routing algorithmRouting algorithm
Routing algorithm
Bushra M
 
Event handling
Event handlingEvent handling
Event handling
swapnac12
 
Servlet and servlet life cycle
Servlet and servlet life cycleServlet and servlet life cycle
Servlet and servlet life cycle
Dhruvin Nakrani
 
Remote Method Invocation (RMI)
Remote Method Invocation (RMI)Remote Method Invocation (RMI)
Remote Method Invocation (RMI)
Peter R. Egli
 
Agents in Artificial intelligence
Agents in Artificial intelligence Agents in Artificial intelligence
Agents in Artificial intelligence
Lalit Birla
 
HTTP request and response
HTTP request and responseHTTP request and response
HTTP request and response
Sahil Agarwal
 
Concurrency Control in Distributed Database.
Concurrency Control in Distributed Database.Concurrency Control in Distributed Database.
Concurrency Control in Distributed Database.
Meghaj Mallick
 
Minmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slidesMinmax Algorithm In Artificial Intelligence slides
Minmax Algorithm In Artificial Intelligence slides
SamiaAziz4
 
Tcpip services and applications
Tcpip services and applicationsTcpip services and applications
Tcpip services and applications
Online
 
Introduction to ajax
Introduction  to  ajaxIntroduction  to  ajax
Introduction to ajax
Pihu Goel
 

Similar to INTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE AND JSP PROCESSING (20)

Jsp basic
Jsp basicJsp basic
Jsp basic
Jaya Kumari
 
JavaScript, often abbreviated as JS, is a programming language and core techn...
JavaScript, often abbreviated as JS, is a programming language and core techn...JavaScript, often abbreviated as JS, is a programming language and core techn...
JavaScript, often abbreviated as JS, is a programming language and core techn...
MathivananP4
 
JSP.pptx
JSP.pptxJSP.pptx
JSP.pptx
NishaRohit6
 
Enterprise java unit-3_chapter-1-jsp
Enterprise  java unit-3_chapter-1-jspEnterprise  java unit-3_chapter-1-jsp
Enterprise java unit-3_chapter-1-jsp
sandeep54552
 
WEB TECHNOLOGIES JSP
WEB TECHNOLOGIES  JSPWEB TECHNOLOGIES  JSP
WEB TECHNOLOGIES JSP
Jyothishmathi Institute of Technology and Science Karimnagar
 
WT Unit-Vuufvmjn dissimilating Dunkirk k
WT Unit-Vuufvmjn dissimilating Dunkirk kWT Unit-Vuufvmjn dissimilating Dunkirk k
WT Unit-Vuufvmjn dissimilating Dunkirk k
asta9578
 
Jsp abes new
Jsp abes newJsp abes new
Jsp abes new
Ashwin Perti
 
Jeetrainers.com coursejspservlets00
Jeetrainers.com coursejspservlets00Jeetrainers.com coursejspservlets00
Jeetrainers.com coursejspservlets00
Rajesh Moorjani
 
Coursejspservlets00
Coursejspservlets00Coursejspservlets00
Coursejspservlets00
Rajesh Moorjani
 
Jsp in Servlet by Rj
Jsp in Servlet by RjJsp in Servlet by Rj
Jsp in Servlet by Rj
Shree M.L.Kakadiya MCA mahila college, Amreli
 
3.jsp tutorial
3.jsp tutorial3.jsp tutorial
3.jsp tutorial
shiva404
 
Wt unit 4
Wt unit 4Wt unit 4
Wt unit 4
team11vgnt
 
Java server pages
Java server pagesJava server pages
Java server pages
Abhishek Kesharwani
 
Jsp interview questions by java training center
Jsp interview questions by java training centerJsp interview questions by java training center
Jsp interview questions by java training center
Maheshit Jtc
 
Spatial approximate string search Doc
Spatial approximate string search DocSpatial approximate string search Doc
Spatial approximate string search Doc
Sudha Hari Tech Solution Pvt ltd
 
JSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESJSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGES
Yoga Raja
 
Jsp
JspJsp
Jsp
Maheshit Jtc
 
Web programming-Introduction to JSP.pptx
Web programming-Introduction to JSP.pptxWeb programming-Introduction to JSP.pptx
Web programming-Introduction to JSP.pptx
mcjaya2024
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
Vikas Jagtap
 
JSP Components and Directives.pdf
JSP Components and Directives.pdfJSP Components and Directives.pdf
JSP Components and Directives.pdf
Arumugam90
 
Ad

Recently uploaded (20)

Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
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
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
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
 
#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
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
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
 
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
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
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
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
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
 
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
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
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
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
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
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
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
 
#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
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
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
 
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
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
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
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
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
 
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
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
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
 
Ad

INTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE AND JSP PROCESSING

  • 1. COURSE:WEB TECHNOLOGIES INTRODUCTION TO JSP,JSP LIFE CYCLE, ANATOMY OF JSP PAGE AND JSP PROCESSING By AAQIB HUSSAIN MODULE-III
  • 2. 2 Course outcome / Topic learning outcome Name of the Topic covered Topic Learning Outcome Course Outcome Introduction to JSP,Anatomy of JSP page and JSP Processing Understand and apply the methods of servlet for request - response paradigm. Develop a server side web application using servlets for request-response programming paradigm List the course outcome / Topic outcome
  • 3. 3 Outcome achieved Name of the topic: Introduction to JSP,Anatomy of JSP page and JSP Processing Students will be able to do: 1 Design the dynamic web pages using HTML and JSP 2
  • 4. JAVA SERVER PAGES Introduction to JSP: • Besides servlets there exists one more java based technology called JSP(Java Server Pages) to develop web applications. • JSP was developed by Sun Micro Systems to allow server side development.JSP is a kind of scripting language in which we can embed java code along with HTML elements. • JSP is textual document that describes how to create a response object from a request object of a given
  • 5. JAVA SERVER PAGES In the processing of JSP include: • A JSP page defines JSP page implementation class that implements the javax.servlet interface. • At the request time ,the request is made to JSP page which will be delivered to the JSP page implementation object for processing. • In any web application a program on server processes request and generate response by using default HTTP protocol.
  • 6. JSP LIFE CYCLE In the processing of JSP include: • The web server needs a JSP engine, i.e, a container to process JSP pages. It resides inside the webserver.The JSP container is responsible for intercepting requests for JSP pages. Compilation process of JSP page involves three steps: • Parsing of JSP • Turning JSP into servlet • Compiling the servlet
  • 7. JSP LIFE CYCLE 1.Translation- demo.jsp page is translated in to Servlet 2.Compilation- Servlet demo_jsp.java is created 3.Class Loading- demo_ jsp.java is loaded in to demo_jsp.class 6.Request Processing- Servlet demo_jsp.java is executed using service method 5.Initiaization- Servlet demo_ljsp is initialized 4.Instantiation- Servlet demo_jsp is instantiated 7.Destroy- Servlet demo_jsp is destroyed
  • 8. Anatomy of JSP A JSP page is a web page with JSP elements for generating the parts that differ for each request.
  • 9. Anatomy of JSP • JSP page is a combination of JSP element and template text. • Template text can be any text which includes HTML, WML, XML, or even plain text. it can be used with any markup language. • Template text is always passed directly to the browser. • When a JSP page request is processed, the template text and dynamic content generated by the JSP elements are merged, and the result is sent as the response to the browser.
  • 10. JSP Processing • A web server needs a servlet container to provide an interface to servlets, the server needs a JSP container to process JSP pages. • The JSP container is responsible for intercepting requests for JSP pages. • To process all JSP elements in the page, the container first turns the JSP page into a servlet (known as the JSP page implementationclass). • The template text is converted to println( ) statements similar to the ones in the hand-coded servlet and all JSP elements are converted to Java code that implements the corresponding dynamic behavior. The container then compiles the servlet class. • Converting the JSP page to a servlet and compiling the servlet form the translation phase.
  • 11. • The JSP container initiates the translation phase for a page automatically when it receives the first request for the page. Since the translation phase takes a bit of time, the first user to request a JSP page notices a slight delay. • The translation phase can also be initiated explicitly and is referred to as pre-compilation of a JSP page. • Pre-compiling a JSP page is a way to avoid hitting the first user with this delay. • The JSP container is also responsible for invoking the JSP page implementation class (the generated servlet) to process each request and generate the response. This is called the request processing phase.
  • 12. The two phases are illustrated in the figure
  • 13. Anatomy of JSP • JSP page is a combination of JSP element and template text. • Template text can be any text which includes HTML, WML, XML, or even plain text. it can be used with any markup language. • Template text is always passed directly to the browser. • When a JSP page request is processed, the template text and dynamic content generated by the JSP elements are merged, and the result is sent as the response to the browser.
  • 14. • As long as the JSP page remains unchanged, any subsequent request goes straight to the request processing phase (i.e., the container simply executes the class file). • When the JSP page is modified, it goes through the translation phase again before entering the request processing phase. • The JSP container is also responsible for invoking the JSP page implementation class (the generated servlet) to process each request and generate the response. This is called the request processing phase.
  • 15. JSP Declarations • A JSP declaration declares one or more variables or methods that one can use in Java code later in the JSP file. • The JSP declaration tag is a piece of java code mainly used to declare fields and methods SYNTAX <%! declaration; [ declaration; ]+ ... %>