SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Core Web Application
Development Using Servlet &
JSP
Bahaa Farouk
                       Organized
                          By
Agenda
• Servlet
   – What is Java Servlet?
   – Servlet Life Cycle
   – Client Interaction & Session
• JSP
   –   What’s JSP?
   –   JSP Life Cycle
   –   What’s JSP Contains?
   –   JSP Scope & Implicit Objects
• Why Servlet & JSP?
Web Application Development?
Agenda
• Servlet
   – What is Java Servlet?
   – Servlet Life Cycle
   – Client Interaction & Session
• JSP
   –   What’s JSP?
   –   JSP Life Cycle
   –   What’s JSP Contains?
   –   JSP Scope & Implicit Objects
• Why Servlet & JSP?
What is Java Servlet?
• An alternate form of server-side computation that
  uses Java
• The Web server is extended to support an API, and
  then Java programs use the API to create dynamic
  web pages
• Using Java servlets provides a platform-independent
  replacement for CGI scripts.
• Servlets can be embedded in many different servers
  because the servlet API, which you use to write
  servlets, assumes nothing about the server's
  environment or protocol.
Servlet Life Cycle
• Initialization
   – the servlet engine loads the servlet’s *.class file in the JVM
     memory space and initializes any objects
• Execution
   – when a servlet request is made,
      • a ServletRequest object is sent with all information about the
        request
      • a ServletResponse object is used to return the response
• Destruction
   – the servlet cleans up allocated resources and shuts down
Client Interaction
• When a servlet accepts a call from a client,
  it receives two objects:
  – A ServletRequest, which encapsulates the
    communication from the client to the server.
  – A ServletResponse, which encapsulates the
    communication from the servlet back to the
    client.
• ServletRequest and ServletResponse are
  interfaces defined by the javax.servlet
  package.
Request Header Example
Request Parameters
Cookies
Session Capabilities
• Session tracking is a mechanism that servlets use to
  maintain state about a series of requests from the
  same user(that is, requests originating from the
  same browser) across some period of time.
• Session tracking capabilities. The servlet writer can
  use these APIs to maintain state between the servlet
  and the client that persists across multiple
  connections during some time period.
Sessions
Agenda
• Servlet
   – What is Java Servlet?
   – Servlet Life Cycle
   – Client Interaction & Session
• JSP
   –   What’s JSP?
   –   JSP Life Cycle
   –   What’s JSP Contains?
   –   JSP Scope & Implicit Objects
• Why Servlet & JSP?
What is JSP?
• A Java Servlet is a Java program that is run on the
  server
   – There are Java classes for retrieving HTTP requests and
     returning HTTP responses
   – Must return an entire HTML page, so all tuning of the page
     must be done in a Java program that needs to be re-
     compiled
• Java Server Pages (JSP)
   – use HTML and XML tags to design the page and JSP scriplet
     tags to generate dynamic content (Easier for separation
     between designer & developer)
   – use Java Beans and useful built-in objects for more
     convenience
JSP Life Cycle
• JSP page (MyFirstJSP.jsp)
   –   Translated to Servle (MyFirstJSP.servlet)
   –   Compiled to class (MyFirstJSP.class)
   –   Loaded into memory (Initialization)
   –   Execution (repeats)
   –   Destruction


• Any change in JSP page automatically repeats the
  whole life cycle.
Introduction
 • A Java Servlet is a Java program that is run on the
   server
    – There are Java classes for retrieving HTTP requests and
      returning HTTP responses
 • Java Server Pages (JSP)
    – use HTML and XML tags to design the page and JSP scriplet
      tags to generate dynamic content
    – use Java Beans, which are reusable components that are
      invoked by scriplets
What do JSPs contain?
• Template data
  – Everything other than elements (eg. Html tags)
• Elements
  – based on XML syntax
     • <somejsptag attribute name=“atrribute value”> BODY
       </somejsptag>
  – Directives
  – Scripting
     • Declarations
     • Scriptles
     • Expressions
  – Standard Actions
Directives
 • <%@ directivename attribute=“value”
   attribute=“value” %>
 • The page directive
    – <%@ page ATTRIBUTES %>
    – language, import, Buffer, errorPage,…
    – <%@ page languange=“java”
      import=“java.rmi.*,java.util.*” %>
 • The include directive
    – <%@ include file=“Filename” %>
    – the static file name to include (included at translation
      time)
 • The taglib directive
    – <% taglib uri=“taglibraryURI” prefix=“tagPrefix” %>
Scripting
(Declaration, Expressions, Scriptlets)
 • <%! . . %> declares variables or methods
    – define class-wide variables
    – <%! int i = 0; %>
    – <%! int a, b; double c: %>
    – <%! Circle a = new Circle(2.0); %>
    – You must declare a variable or method in a jsp page before
      you use it
    – The scope of a declaration is the jsp file, extending to all
      includes

 • <%= . . %> defines an expression and casts the result
   as a string
Scripting II
  • <%= . . %> can contain any language expression, but
    without a semicolon, e.g.
  • <%= Math.sqrt(2) %>
  • <%= items[I] %>
  • <%= a + b + c %>
  • <%= new java.util.Date() %>
  • <% . . %> can handle declarations (page scope),
    expressions, or any other type of code fragment
  • <% for(int I = 0; I < 10; I++) {
        out.println(“<B> Hello World: “ + I);       } %>
JSP and Scope
• Page - objects with page scope are accessible only within the
  page where they are created
• Request - objects with request scope are accessible from
  pages processing the same request where they were created
• Session - ojbects with session scope are accessible from pages
  processing requests that are in the same session as the one in
  which they were created
• Application - objects with application scope are accessible
  from pages processing requests that are in the same
  application as the one in which they were created
• All the different scopes behave as a single name space
Implicit Objects
• These objects do not need to be declared or instantiated by
  the JSP author, but are provided by the container (jsp engine)
  in the implementation class
• request Object (javax.servlet.ServletRequest)
• response Object (javax.servlet.ServletResponse)
• session Object (javax.servlet.http.HttpSession)
• application Object
• out Object
• config Object
• page Object
• pageContext Object (javax.servlet.jsp.PageContext)
• exception
Number guess - Browser Output
Agenda
• Servlet
   – What is Java Servlet?
   – Servlet Life Cycle
   – Client Interaction & Session
• JSP
   –   What’s JSP?
   –   JSP Life Cycle
   –   What’s JSP Contains?
   –   JSP Scope & Implicit Objects
• Why Servlet & JSP?
Why Servlet/JSP?
What is an Enterprise Application?
 •   Reliable
 •   Scalable
 •   Maintainable
 •   Manageable

     – If you are developing an Enterprise Application for
     whose daily transactions are millions?
        • Performance? Scalability? Reliability?
Questions ?

Weitere ähnliche Inhalte

Was ist angesagt?

Javax.servlet,http packages
Javax.servlet,http packagesJavax.servlet,http packages
Javax.servlet,http packagesvamsi krishna
 
Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jspJafar Nesargi
 
Web Tech Java Servlet Update1
Web Tech   Java Servlet Update1Web Tech   Java Servlet Update1
Web Tech Java Servlet Update1vikram singh
 
Java servlets
Java servletsJava servlets
Java servletslopjuan
 
Java Servlets
Java ServletsJava Servlets
Java ServletsEmprovise
 
Java Servlets
Java ServletsJava Servlets
Java ServletsNitin Pai
 
Servlet and servlet life cycle
Servlet and servlet life cycleServlet and servlet life cycle
Servlet and servlet life cycleDhruvin Nakrani
 
1 java servlets and jsp
1   java servlets and jsp1   java servlets and jsp
1 java servlets and jspAnkit Minocha
 
Java servlet technology
Java servlet technologyJava servlet technology
Java servlet technologyMinal Maniar
 
Servlet/JSP course chapter 1: Introduction to servlets
Servlet/JSP course chapter 1: Introduction to servletsServlet/JSP course chapter 1: Introduction to servlets
Servlet/JSP course chapter 1: Introduction to servletsJavaEE Trainers
 
Servlet.ppt
Servlet.pptServlet.ppt
Servlet.pptVMahesh5
 
Servlet and JSP
Servlet and JSPServlet and JSP
Servlet and JSPGary Yeh
 
Java EE 01-Servlets and Containers
Java EE 01-Servlets and ContainersJava EE 01-Servlets and Containers
Java EE 01-Servlets and ContainersFernando Gil
 

Was ist angesagt? (20)

Servlets
ServletsServlets
Servlets
 
JAVA Servlets
JAVA ServletsJAVA Servlets
JAVA Servlets
 
Javax.servlet,http packages
Javax.servlet,http packagesJavax.servlet,http packages
Javax.servlet,http packages
 
Servlet
Servlet Servlet
Servlet
 
Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jsp
 
Web Tech Java Servlet Update1
Web Tech   Java Servlet Update1Web Tech   Java Servlet Update1
Web Tech Java Servlet Update1
 
Java servlets
Java servletsJava servlets
Java servlets
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Java Servlets & JSP
Java Servlets & JSPJava Servlets & JSP
Java Servlets & JSP
 
Servlet and servlet life cycle
Servlet and servlet life cycleServlet and servlet life cycle
Servlet and servlet life cycle
 
1 java servlets and jsp
1   java servlets and jsp1   java servlets and jsp
1 java servlets and jsp
 
Java servlet technology
Java servlet technologyJava servlet technology
Java servlet technology
 
Servlet/JSP course chapter 1: Introduction to servlets
Servlet/JSP course chapter 1: Introduction to servletsServlet/JSP course chapter 1: Introduction to servlets
Servlet/JSP course chapter 1: Introduction to servlets
 
Servlets
ServletsServlets
Servlets
 
Java servlets
Java servletsJava servlets
Java servlets
 
Servlet.ppt
Servlet.pptServlet.ppt
Servlet.ppt
 
Servlets
ServletsServlets
Servlets
 
Servlet and JSP
Servlet and JSPServlet and JSP
Servlet and JSP
 
Java EE 01-Servlets and Containers
Java EE 01-Servlets and ContainersJava EE 01-Servlets and Containers
Java EE 01-Servlets and Containers
 

Andere mochten auch

Be Part Of Software Development
Be Part Of Software DevelopmentBe Part Of Software Development
Be Part Of Software DevelopmentBahaa Farouk
 
Career building and Skills Development
Career building and Skills DevelopmentCareer building and Skills Development
Career building and Skills DevelopmentBahaa Farouk
 
SCRUM Development Process
SCRUM Development ProcessSCRUM Development Process
SCRUM Development ProcessBahaa Farouk
 
System requirement specification report(srs) T/TN/Gomarankadawala Maha vidyal...
System requirement specification report(srs) T/TN/Gomarankadawala Maha vidyal...System requirement specification report(srs) T/TN/Gomarankadawala Maha vidyal...
System requirement specification report(srs) T/TN/Gomarankadawala Maha vidyal...Ravindu Sandeepa
 
Scrum Agile Methodlogy
Scrum Agile MethodlogyScrum Agile Methodlogy
Scrum Agile MethodlogyBahaa Farouk
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applicationshchen1
 
Web Application Development
Web Application DevelopmentWeb Application Development
Web Application DevelopmentWhytespace Ltd.
 
Oracle ADF Overview
Oracle ADF OverviewOracle ADF Overview
Oracle ADF OverviewBahaa Farouk
 
Agile Overview Session
Agile Overview SessionAgile Overview Session
Agile Overview SessionBahaa Farouk
 
Web Application Development Fundamentals
Web Application Development FundamentalsWeb Application Development Fundamentals
Web Application Development FundamentalsMohammed Makhlouf
 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods pptkamal kotecha
 
Web Development on Web Project Presentation
Web Development on Web Project PresentationWeb Development on Web Project Presentation
Web Development on Web Project PresentationMilind Gokhale
 
Ppt of web development
Ppt of web developmentPpt of web development
Ppt of web developmentbethanygfair
 
Website Development and Design Proposal
Website Development and Design ProposalWebsite Development and Design Proposal
Website Development and Design ProposalCreative 3D Design
 
java Project report online banking system
java Project report online banking systemjava Project report online banking system
java Project report online banking systemVishNu KuNtal
 

Andere mochten auch (19)

M-Brokrage
M-BrokrageM-Brokrage
M-Brokrage
 
Be Part Of Software Development
Be Part Of Software DevelopmentBe Part Of Software Development
Be Part Of Software Development
 
QualiTech Profile
QualiTech ProfileQualiTech Profile
QualiTech Profile
 
Career building and Skills Development
Career building and Skills DevelopmentCareer building and Skills Development
Career building and Skills Development
 
Being Architect
Being ArchitectBeing Architect
Being Architect
 
SCRUM Development Process
SCRUM Development ProcessSCRUM Development Process
SCRUM Development Process
 
System requirement specification report(srs) T/TN/Gomarankadawala Maha vidyal...
System requirement specification report(srs) T/TN/Gomarankadawala Maha vidyal...System requirement specification report(srs) T/TN/Gomarankadawala Maha vidyal...
System requirement specification report(srs) T/TN/Gomarankadawala Maha vidyal...
 
Scrum Agile Methodlogy
Scrum Agile MethodlogyScrum Agile Methodlogy
Scrum Agile Methodlogy
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
 
Web Application Development
Web Application DevelopmentWeb Application Development
Web Application Development
 
Oracle ADF Overview
Oracle ADF OverviewOracle ADF Overview
Oracle ADF Overview
 
Agile Overview Session
Agile Overview SessionAgile Overview Session
Agile Overview Session
 
ESB Overview
ESB OverviewESB Overview
ESB Overview
 
Web Application Development Fundamentals
Web Application Development FundamentalsWeb Application Development Fundamentals
Web Application Development Fundamentals
 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods ppt
 
Web Development on Web Project Presentation
Web Development on Web Project PresentationWeb Development on Web Project Presentation
Web Development on Web Project Presentation
 
Ppt of web development
Ppt of web developmentPpt of web development
Ppt of web development
 
Website Development and Design Proposal
Website Development and Design ProposalWebsite Development and Design Proposal
Website Development and Design Proposal
 
java Project report online banking system
java Project report online banking systemjava Project report online banking system
java Project report online banking system
 

Ähnlich wie Core web application development

Ähnlich wie Core web application development (20)

Jeetrainers.com coursejspservlets00
Jeetrainers.com coursejspservlets00Jeetrainers.com coursejspservlets00
Jeetrainers.com coursejspservlets00
 
Coursejspservlets00
Coursejspservlets00Coursejspservlets00
Coursejspservlets00
 
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...
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Jsp basic
Jsp basicJsp basic
Jsp basic
 
20jsp
20jsp20jsp
20jsp
 
Jsp
JspJsp
Jsp
 
Jsp
JspJsp
Jsp
 
JSP - Java Server Page
JSP - Java Server PageJSP - Java Server Page
JSP - Java Server Page
 
Advance java session 9
Advance java session 9Advance java session 9
Advance java session 9
 
Wt unit 3 server side technology
Wt unit 3 server side technologyWt unit 3 server side technology
Wt unit 3 server side technology
 
Wt unit 3 server side technology
Wt unit 3 server side technologyWt unit 3 server side technology
Wt unit 3 server side technology
 
Advance java1.1
Advance java1.1Advance java1.1
Advance java1.1
 
Jsp
JspJsp
Jsp
 
Advance java session 10
Advance java session 10Advance java session 10
Advance java session 10
 
Java Servlets.pdf
Java Servlets.pdfJava Servlets.pdf
Java Servlets.pdf
 
Ch. 7 beeing a jsp
Ch. 7 beeing a jsp     Ch. 7 beeing a jsp
Ch. 7 beeing a jsp
 
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
 
005432796.pdf
005432796.pdf005432796.pdf
005432796.pdf
 
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
192563547-Servletsjhb,mnjhjhjm,nm,-Pres-ppt.ppt
 

Kürzlich hochgeladen

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 

Kürzlich hochgeladen (20)

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 

Core web application development

  • 1. Core Web Application Development Using Servlet & JSP Bahaa Farouk Organized By
  • 2. Agenda • Servlet – What is Java Servlet? – Servlet Life Cycle – Client Interaction & Session • JSP – What’s JSP? – JSP Life Cycle – What’s JSP Contains? – JSP Scope & Implicit Objects • Why Servlet & JSP?
  • 4. Agenda • Servlet – What is Java Servlet? – Servlet Life Cycle – Client Interaction & Session • JSP – What’s JSP? – JSP Life Cycle – What’s JSP Contains? – JSP Scope & Implicit Objects • Why Servlet & JSP?
  • 5. What is Java Servlet? • An alternate form of server-side computation that uses Java • The Web server is extended to support an API, and then Java programs use the API to create dynamic web pages • Using Java servlets provides a platform-independent replacement for CGI scripts. • Servlets can be embedded in many different servers because the servlet API, which you use to write servlets, assumes nothing about the server's environment or protocol.
  • 6. Servlet Life Cycle • Initialization – the servlet engine loads the servlet’s *.class file in the JVM memory space and initializes any objects • Execution – when a servlet request is made, • a ServletRequest object is sent with all information about the request • a ServletResponse object is used to return the response • Destruction – the servlet cleans up allocated resources and shuts down
  • 7. Client Interaction • When a servlet accepts a call from a client, it receives two objects: – A ServletRequest, which encapsulates the communication from the client to the server. – A ServletResponse, which encapsulates the communication from the servlet back to the client. • ServletRequest and ServletResponse are interfaces defined by the javax.servlet package.
  • 11. Session Capabilities • Session tracking is a mechanism that servlets use to maintain state about a series of requests from the same user(that is, requests originating from the same browser) across some period of time. • Session tracking capabilities. The servlet writer can use these APIs to maintain state between the servlet and the client that persists across multiple connections during some time period.
  • 13. Agenda • Servlet – What is Java Servlet? – Servlet Life Cycle – Client Interaction & Session • JSP – What’s JSP? – JSP Life Cycle – What’s JSP Contains? – JSP Scope & Implicit Objects • Why Servlet & JSP?
  • 14. What is JSP? • A Java Servlet is a Java program that is run on the server – There are Java classes for retrieving HTTP requests and returning HTTP responses – Must return an entire HTML page, so all tuning of the page must be done in a Java program that needs to be re- compiled • Java Server Pages (JSP) – use HTML and XML tags to design the page and JSP scriplet tags to generate dynamic content (Easier for separation between designer & developer) – use Java Beans and useful built-in objects for more convenience
  • 15. JSP Life Cycle • JSP page (MyFirstJSP.jsp) – Translated to Servle (MyFirstJSP.servlet) – Compiled to class (MyFirstJSP.class) – Loaded into memory (Initialization) – Execution (repeats) – Destruction • Any change in JSP page automatically repeats the whole life cycle.
  • 16. Introduction • A Java Servlet is a Java program that is run on the server – There are Java classes for retrieving HTTP requests and returning HTTP responses • Java Server Pages (JSP) – use HTML and XML tags to design the page and JSP scriplet tags to generate dynamic content – use Java Beans, which are reusable components that are invoked by scriplets
  • 17. What do JSPs contain? • Template data – Everything other than elements (eg. Html tags) • Elements – based on XML syntax • <somejsptag attribute name=“atrribute value”> BODY </somejsptag> – Directives – Scripting • Declarations • Scriptles • Expressions – Standard Actions
  • 18. Directives • <%@ directivename attribute=“value” attribute=“value” %> • The page directive – <%@ page ATTRIBUTES %> – language, import, Buffer, errorPage,… – <%@ page languange=“java” import=“java.rmi.*,java.util.*” %> • The include directive – <%@ include file=“Filename” %> – the static file name to include (included at translation time) • The taglib directive – <% taglib uri=“taglibraryURI” prefix=“tagPrefix” %>
  • 19. Scripting (Declaration, Expressions, Scriptlets) • <%! . . %> declares variables or methods – define class-wide variables – <%! int i = 0; %> – <%! int a, b; double c: %> – <%! Circle a = new Circle(2.0); %> – You must declare a variable or method in a jsp page before you use it – The scope of a declaration is the jsp file, extending to all includes • <%= . . %> defines an expression and casts the result as a string
  • 20. Scripting II • <%= . . %> can contain any language expression, but without a semicolon, e.g. • <%= Math.sqrt(2) %> • <%= items[I] %> • <%= a + b + c %> • <%= new java.util.Date() %> • <% . . %> can handle declarations (page scope), expressions, or any other type of code fragment • <% for(int I = 0; I < 10; I++) { out.println(“<B> Hello World: “ + I); } %>
  • 21. JSP and Scope • Page - objects with page scope are accessible only within the page where they are created • Request - objects with request scope are accessible from pages processing the same request where they were created • Session - ojbects with session scope are accessible from pages processing requests that are in the same session as the one in which they were created • Application - objects with application scope are accessible from pages processing requests that are in the same application as the one in which they were created • All the different scopes behave as a single name space
  • 22. Implicit Objects • These objects do not need to be declared or instantiated by the JSP author, but are provided by the container (jsp engine) in the implementation class • request Object (javax.servlet.ServletRequest) • response Object (javax.servlet.ServletResponse) • session Object (javax.servlet.http.HttpSession) • application Object • out Object • config Object • page Object • pageContext Object (javax.servlet.jsp.PageContext) • exception
  • 23. Number guess - Browser Output
  • 24. Agenda • Servlet – What is Java Servlet? – Servlet Life Cycle – Client Interaction & Session • JSP – What’s JSP? – JSP Life Cycle – What’s JSP Contains? – JSP Scope & Implicit Objects • Why Servlet & JSP?
  • 25. Why Servlet/JSP? What is an Enterprise Application? • Reliable • Scalable • Maintainable • Manageable – If you are developing an Enterprise Application for whose daily transactions are millions? • Performance? Scalability? Reliability?