SlideShare a Scribd company logo
1 of 15
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; ]+ ... %>

More Related Content

What's hot

anatomy of a jsp page & jsp syntax.pptx
anatomy of a jsp page & jsp syntax.pptxanatomy of a jsp page & jsp syntax.pptx
anatomy of a jsp page & jsp syntax.pptxSameenafathima4
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaCPD INDIA
 
Communication primitives
Communication primitivesCommunication primitives
Communication primitivesStudent
 
Fault tolerance in distributed systems
Fault tolerance in distributed systemsFault tolerance in distributed systems
Fault tolerance in distributed systemssumitjain2013
 
jstl ( jsp standard tag library )
jstl ( jsp standard tag library )jstl ( jsp standard tag library )
jstl ( jsp standard tag library )Adarsh Patel
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object ModelWebStackAcademy
 
Model Based Software Architectures
Model Based Software ArchitecturesModel Based Software Architectures
Model Based Software ArchitecturesMunazza-Mah-Jabeen
 
Servlet and servlet life cycle
Servlet and servlet life cycleServlet and servlet life cycle
Servlet and servlet life cycleDhruvin Nakrani
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVAVINOTH R
 
Multilayer & Back propagation algorithm
Multilayer & Back propagation algorithmMultilayer & Back propagation algorithm
Multilayer & Back propagation algorithmswapnac12
 

What's hot (20)

Ajax ppt
Ajax pptAjax ppt
Ajax ppt
 
Code generation
Code generationCode generation
Code generation
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
 
anatomy of a jsp page & jsp syntax.pptx
anatomy of a jsp page & jsp syntax.pptxanatomy of a jsp page & jsp syntax.pptx
anatomy of a jsp page & jsp syntax.pptx
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
 
Google App Engine
Google App EngineGoogle App Engine
Google App Engine
 
Servlets
ServletsServlets
Servlets
 
unit 3 Design 1
unit 3 Design 1unit 3 Design 1
unit 3 Design 1
 
Java rmi
Java rmiJava rmi
Java rmi
 
Communication primitives
Communication primitivesCommunication primitives
Communication primitives
 
Applets
AppletsApplets
Applets
 
Tcp/ip server sockets
Tcp/ip server socketsTcp/ip server sockets
Tcp/ip server sockets
 
Fault tolerance in distributed systems
Fault tolerance in distributed systemsFault tolerance in distributed systems
Fault tolerance in distributed systems
 
jstl ( jsp standard tag library )
jstl ( jsp standard tag library )jstl ( jsp standard tag library )
jstl ( jsp standard tag library )
 
Distributed DBMS - Unit 5 - Semantic Data Control
Distributed DBMS - Unit 5 - Semantic Data ControlDistributed DBMS - Unit 5 - Semantic Data Control
Distributed DBMS - Unit 5 - Semantic Data Control
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
 
Model Based Software Architectures
Model Based Software ArchitecturesModel Based Software Architectures
Model Based Software Architectures
 
Servlet and servlet life cycle
Servlet and servlet life cycleServlet and servlet life cycle
Servlet and servlet life cycle
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
 
Multilayer & Back propagation algorithm
Multilayer & Back propagation algorithmMultilayer & Back propagation algorithm
Multilayer & Back propagation algorithm
 

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

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

Jsp basic
Jsp basicJsp basic
Jsp basic
 
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...
 
JSP.pptx
JSP.pptxJSP.pptx
JSP.pptx
 
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
 
WEB TECHNOLOGIES JSP
WEB TECHNOLOGIES  JSPWEB TECHNOLOGIES  JSP
WEB TECHNOLOGIES JSP
 
Jsp abes new
Jsp abes newJsp abes new
Jsp abes new
 
Jeetrainers.com coursejspservlets00
Jeetrainers.com coursejspservlets00Jeetrainers.com coursejspservlets00
Jeetrainers.com coursejspservlets00
 
Coursejspservlets00
Coursejspservlets00Coursejspservlets00
Coursejspservlets00
 
Jsp in Servlet by Rj
Jsp in Servlet by RjJsp in Servlet by Rj
Jsp in Servlet by Rj
 
3.jsp tutorial
3.jsp tutorial3.jsp tutorial
3.jsp tutorial
 
Wt unit 4
Wt unit 4Wt unit 4
Wt unit 4
 
Java server pages
Java server pagesJava server pages
Java server pages
 
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
 
Spatial approximate string search Doc
Spatial approximate string search DocSpatial approximate string search Doc
Spatial approximate string search Doc
 
JSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESJSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGES
 
Jsp
JspJsp
Jsp
 
JSP Components and Directives.pdf
JSP Components and Directives.pdfJSP Components and Directives.pdf
JSP Components and Directives.pdf
 
Jsp session 1
Jsp   session 1Jsp   session 1
Jsp session 1
 
Project First presentation about introduction to technologies to be used
Project First presentation about introduction to technologies to be usedProject First presentation about introduction to technologies to be used
Project First presentation about introduction to technologies to be used
 
Java JSP.pptx
Java JSP.pptxJava JSP.pptx
Java JSP.pptx
 

Recently uploaded

Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Skynet Technologies
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptxFIDO Alliance
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxjbellis
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxFIDO Alliance
 
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The InsideCollecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The InsideStefan Dietze
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...FIDO Alliance
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...FIDO Alliance
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfalexjohnson7307
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfFIDO Alliance
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...ScyllaDB
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxFIDO Alliance
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe中 央社
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Paige Cruz
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024Lorenzo Miniero
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data SciencePaolo Missier
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfFIDO Alliance
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightSafe Software
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTopCSSGallery
 

Recently uploaded (20)

Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
 
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The InsideCollecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 

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; ]+ ... %>