SlideShare a Scribd company logo
Working with Java Server Pages
Agenda
• Understand the need for Java Server pages
• Evaluating the benefits of Java Server pages(JSP)
• Understanding JSP Lifecycle
• Installing JSP pages
Need for JSP
• JSP is a template page technology
- High level abstraction of Servlets
• Separation of presentation from logic
• Even non java programmer can create JSP pages with reasonable ease
JSP Introduction
• Idea:
- Use regular HTML for most of page
- Mark servlet code with special tags
- Entire JSP page gets translated into a servlet (once), and
- servlet is what actually gets invoked (for each request)
• Example:
<!DOCTYPE …><HTML><HEAD><TITLE>Order Confirmation</TITLE>
<LINK REL=STYLESHEET HREF="JSP-Styles.css” TYPE="text/css">
</HEAD><BODY><H2>Order Confirmation</H2>
Thanks for ordering
<I><%= request.getParameter("title") %></I>!
</BODY></HTML>
JSP lifeCycle
• Translation
- JSP page is translated into a Servlet by JSP container
• Compilation
- The generated file is compiled into a servlet.
• Class Loading
- The generated Servlet is then loaded in the container
• Execution
- The loaded JSP is executing by the container in response to request and
calling the lifecycle methods
JSP lifeCycle(cont)
• Initialization
- JspInit() method is called immediately after the instance was created.
• _jspService() execution
- This method is called for every request of the JSP during lifecycle
- This method cannot be overridden by the page author
• jspDestroy()
- This method is called when the jsp is destroyed.
• jspInit(),_jspService(), jspDestroy() are the lifecycle methods of JSP
Benefits of JSP
• Simple to use
• Requires little of no knowledge of java
• Platform independent (built of java)
• Easy to learn and migrate being similar to PHP and ASP
• Well Documented
Installing JSP
• JSP is part of JEE specification
• It’s library is available in all the JEE compliant Server
• We need to create JSP File in the context-root
• No need to
- set classpath
- Compile
- Configure xml
Summary
• JSP makes it easier to create and maintain HTML, while still
providing full access to servlet code
• JSP pages get translated into servlets
- It is the servlets that run at request time
- Client does not see anything JSP-related
• You still need to understand servlets
- Understanding how JSP really works
- Servlet code called from JSP
- Knowing when servlets are better than JSP
- Mixing servlets and JSP
• Other technologies use similar approach, but aren't as portable and
don't let you use Java for the "real code

More Related Content

PPT
Jsp Comparison
PPT
Jsp(java server pages)
PDF
Jeetrainers.com coursejspservlets00
PDF
Being a jsp
PDF
4η διάλεξη Τεχνολογίες Παγκόσμιου Ιστού
PDF
Ch. 7 beeing a jsp
PDF
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 2...
PPTX
Enterprise Java
Jsp Comparison
Jsp(java server pages)
Jeetrainers.com coursejspservlets00
Being a jsp
4η διάλεξη Τεχνολογίες Παγκόσμιου Ιστού
Ch. 7 beeing a jsp
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 2...
Enterprise Java

What's hot (19)

PPTX
Eenterprises Java
PDF
Ch. 11 deploying
PDF
Ch. 13 filters and wrappers
PDF
Ch5 beeing an application
PDF
Shootout! Template engines for the JVM
PPTX
Jsp basic
PPTX
Introdcution to Adobe CQ
PPTX
MVVM Windows UWP apps with Template 10
PPT
Drupalcamp Estonia - High Performance Sites
PPS
MySQL Optimization from a Developer's point of view
PPTX
Challenges of angular in production (Tasos Bekos) - GreeceJS #17
PDF
Metarefresh
PPT
Zend framework 02 - mvc
PDF
Multi-tenant Database Design for SaaS
PPTX
Web Development Today
PPTX
Beanshell scripting in Apache JMeter
PDF
Reactjs workshop
PPTX
Javascript
Eenterprises Java
Ch. 11 deploying
Ch. 13 filters and wrappers
Ch5 beeing an application
Shootout! Template engines for the JVM
Jsp basic
Introdcution to Adobe CQ
MVVM Windows UWP apps with Template 10
Drupalcamp Estonia - High Performance Sites
MySQL Optimization from a Developer's point of view
Challenges of angular in production (Tasos Bekos) - GreeceJS #17
Metarefresh
Zend framework 02 - mvc
Multi-tenant Database Design for SaaS
Web Development Today
Beanshell scripting in Apache JMeter
Reactjs workshop
Javascript
Ad

Similar to Advance java session 9 (20)

PDF
Enterprise java unit-3_chapter-1-jsp
PPT
JSP 1.pptdfdfdfdsfdsfdsfdsfdsgdgdgdgdgdd
DOCX
Java server pages
PPTX
Wt unit 4
PPTX
Java Server Pages(jsp)
PPTX
JSP overview
PPTX
Jsp session 1
PPTX
JAVA SERVER PAGES
DOCX
Unit 4 1 web technology uptu
DOCX
Unit 4 web technology uptu
PPTX
WT Unit-Vuufvmjn dissimilating Dunkirk k
PDF
PPTX
JavaScript, often abbreviated as JS, is a programming language and core techn...
PPT
Jsp abes new
PPTX
The Java Server Page in Java Concept.pptx
PPTX
Jsp Introduction Tutorial
ODP
servlets and jsp
PPTX
Module 3.pptx.............................
PDF
Java Server Pages
Enterprise java unit-3_chapter-1-jsp
JSP 1.pptdfdfdfdsfdsfdsfdsfdsgdgdgdgdgdd
Java server pages
Wt unit 4
Java Server Pages(jsp)
JSP overview
Jsp session 1
JAVA SERVER PAGES
Unit 4 1 web technology uptu
Unit 4 web technology uptu
WT Unit-Vuufvmjn dissimilating Dunkirk k
JavaScript, often abbreviated as JS, is a programming language and core techn...
Jsp abes new
The Java Server Page in Java Concept.pptx
Jsp Introduction Tutorial
servlets and jsp
Module 3.pptx.............................
Java Server Pages
Ad

More from Smita B Kumar (20)

PPTX
Advance java session 20
PPTX
Advance java session 19
PPTX
Advance java session 18
PPTX
Advance java session 17
PPTX
Advance java session 16
PPTX
Advance java session 15
PPTX
Advance java session 14
PPTX
Advance java session 13
PPTX
Advance java session 12
PPTX
Advance java session 11
PPTX
Advance java session 10
PPTX
Advance java session 8
PPTX
Advance java session 7
PPTX
Advance java session 6
PPTX
Advance java session 5
PPTX
Advance java session 4
PPTX
Advance java session 3
PPTX
Advance java session 2
PPTX
JEE session 1
PPTX
01 introduction to struts2
Advance java session 20
Advance java session 19
Advance java session 18
Advance java session 17
Advance java session 16
Advance java session 15
Advance java session 14
Advance java session 13
Advance java session 12
Advance java session 11
Advance java session 10
Advance java session 8
Advance java session 7
Advance java session 6
Advance java session 5
Advance java session 4
Advance java session 3
Advance java session 2
JEE session 1
01 introduction to struts2

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Machine learning based COVID-19 study performance prediction
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Approach and Philosophy of On baking technology
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPT
Teaching material agriculture food technology
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
NewMind AI Weekly Chronicles - August'25 Week I
Chapter 3 Spatial Domain Image Processing.pdf
Spectroscopy.pptx food analysis technology
Unlocking AI with Model Context Protocol (MCP)
MYSQL Presentation for SQL database connectivity
Machine learning based COVID-19 study performance prediction
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Approach and Philosophy of On baking technology
Spectral efficient network and resource selection model in 5G networks
20250228 LYD VKU AI Blended-Learning.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Teaching material agriculture food technology
MIND Revenue Release Quarter 2 2025 Press Release
Programs and apps: productivity, graphics, security and other tools
Understanding_Digital_Forensics_Presentation.pptx
Encapsulation_ Review paper, used for researhc scholars
Big Data Technologies - Introduction.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Diabetes mellitus diagnosis method based random forest with bat algorithm

Advance java session 9

  • 1. Working with Java Server Pages
  • 2. Agenda • Understand the need for Java Server pages • Evaluating the benefits of Java Server pages(JSP) • Understanding JSP Lifecycle • Installing JSP pages
  • 3. Need for JSP • JSP is a template page technology - High level abstraction of Servlets • Separation of presentation from logic • Even non java programmer can create JSP pages with reasonable ease
  • 4. JSP Introduction • Idea: - Use regular HTML for most of page - Mark servlet code with special tags - Entire JSP page gets translated into a servlet (once), and - servlet is what actually gets invoked (for each request) • Example: <!DOCTYPE …><HTML><HEAD><TITLE>Order Confirmation</TITLE> <LINK REL=STYLESHEET HREF="JSP-Styles.css” TYPE="text/css"> </HEAD><BODY><H2>Order Confirmation</H2> Thanks for ordering <I><%= request.getParameter("title") %></I>! </BODY></HTML>
  • 5. JSP lifeCycle • Translation - JSP page is translated into a Servlet by JSP container • Compilation - The generated file is compiled into a servlet. • Class Loading - The generated Servlet is then loaded in the container • Execution - The loaded JSP is executing by the container in response to request and calling the lifecycle methods
  • 6. JSP lifeCycle(cont) • Initialization - JspInit() method is called immediately after the instance was created. • _jspService() execution - This method is called for every request of the JSP during lifecycle - This method cannot be overridden by the page author • jspDestroy() - This method is called when the jsp is destroyed. • jspInit(),_jspService(), jspDestroy() are the lifecycle methods of JSP
  • 7. Benefits of JSP • Simple to use • Requires little of no knowledge of java • Platform independent (built of java) • Easy to learn and migrate being similar to PHP and ASP • Well Documented
  • 8. Installing JSP • JSP is part of JEE specification • It’s library is available in all the JEE compliant Server • We need to create JSP File in the context-root • No need to - set classpath - Compile - Configure xml
  • 9. Summary • JSP makes it easier to create and maintain HTML, while still providing full access to servlet code • JSP pages get translated into servlets - It is the servlets that run at request time - Client does not see anything JSP-related • You still need to understand servlets - Understanding how JSP really works - Servlet code called from JSP - Knowing when servlets are better than JSP - Mixing servlets and JSP • Other technologies use similar approach, but aren't as portable and don't let you use Java for the "real code