SlideShare a Scribd company logo
1 of 13
Download to read offline
Introduction to
    Java Enterprise Edition
    ●   First steps with Servlet Technology.
Servlet Container & Application Server
●



                           Fernando Gil
                            Fernando Gil
                       lobho.gil@gmail.com
                        lobho.gil@gmail.com
                           Marzo 2012
                            Marzo 2012
Introduction
●   The goal of this course is to explain you how can
    you start to develop Java EE applications.


●   We will accomplished our goals by presenting the
    theory behind the concepts of Servlets and
    JavaServer Pages.


●   Using JBoss AS or similar we'll present practical
    exercises to support all the knowledge obtained.
A Servlet is...
●   A server-side entity.
●   A Java programming language class used to extend the
    capabilities of servers that host applications access via a
    request-response programming model.
●   The Java counterpart to non-Java dynamic Web content
    technologies such as CGI and ASP.NET.
Server Responsibilities
●   Every server has two main responsibilities:
    ●   Handle Client Requests.
    ●   Create a response to the clients. In the
        case of HTTP servers that host web
        applications this could be a difficult task
        because they need to create dynamic web
        contents, which may include complicated
        tasks such as retrieving information from
        the database, apply business rules and
        present the information in specific views.
        The best way to perform this responsibility
        is create server extensions that we know as
        Servlets.
Servlet Container
●   To deploy and run a servlet, a Web server uses a separate
    module. This specialized module is called Web container or
    servlet container and is responsible for managing the lifecycle of
    servlets, mapping a URL to a particular servlet and ensuring that
    the URL requester has the correct access rights.
●   The next picture shows how different components fit together.
    The file system stores HTML files, the Servlet container execute
    the Servlets, and business data is in the database. The Web
    browser sends requests to the Web server. If the target is an
    HTML file, the server handles it directly but If the target is a
    servlet then the server delegates the request to the servlet
    container, once there, the servlet can use the file system and
    database to generate dynamic output.
All pieces together
Servlet container types
Conceptually, a servlet container is a part of the web server, even though
it may run in a separate process. We can classify the servlet container in
three types:
●   Standalone: Are typically Java-based servers where the servlet
    container and the web server are integral part of a single program.
    One common example is Tomcat running by itself.
●   In-process: The servlet container is separated from the web server,
    because is a different program, but runs within the address space of
    the main server as a plug-in. One example is Tomcat running inside
    JBoss.
●   Out-of-process: The servlet container and the web server are
    different programs and both run in a different process. To perform
    communications between them, the web server uses a plug-in
    usually provided by the servlet container vendor.
Relationship between Servlet
       Container & Servlet API
●   Java's Servlet specification provides a standard and
    platform-independent framework for communication
    between servlets and their containers. All the servlet
    containers must provide this API.
●   This framework is made up of a set of interfaces an
    classes which are collectively called the Servlet
    Application Programming Interfaces.
●   The Servlet API is divided into        two   packages:
    javax.servlet and javax.servlet.http
javax.servlet
●   This package contains the generic interfaces and classes that are
    independent of any protocol.

       Name                Brief Description
       Servlet interface   This is the central interface in the API. Every class
                           must directly or indirectly implements this interface.

       GenericServlet      It is an abstract class that provides implementation
       class               for all the methods except the service() method of the
                           Servlet interface
       ServletRequest      Provides a generic view of the request that was sent
       interface           by a client and defines methods that extract
                           information form the request.
       ServletResponse     Provides a generic way of sending responses to the
       interface           client.
javax.servlet.http
●   This package contains the basic functionality required for HTTP servlets.
    Interfaces an classes in this package extend the corresponding interfaces an
    classes of the javax.servlet package.
      Name                  Brief Description
      HttpServlet class     Is an abstract class that extends GenericSevlet. It
                            adds a new service() method.

      HttpServletRequest    Extends ServletRequest and provides an HTTP-
      interface             specific view of the request. It defines methods
                            that extract information such as HTTP headers an
                            cookies from the request.
      HttpServletResponse   Extends ServletResponse and provides an HTTP-
      interface             specific way of sending responses. It defines
                            methods that assist in setting information, such as
                            HTTP headers and cookies into the response.
Advantages of the Servlet API

Advantage          Description

Flexibility        If we need to extend the server
                   functionality all we have to do is write a
                   new servlet specific for that requirement
                   without modifying the server itself.
Separation of      The server only needs to worry about
responsibilities   network and communication, while the
                   servlet interprets and response to every
                   client request.
Java language      Java programmers do not need to lear a
                   new language.
Portability        We can write a servlet in one container,
                   and deploy it in another.
Disadvantages of the Servlet API

●   One disadvantage, rather restriction is that
    you have to stick to the rules set for the
    framework to make the container happy.
●   Theoretically using the API you can write
    servlets for almost any kind of protocol but,
    by the moment, the Servlet specification
    only demands support to HTTP.

More Related Content

What's hot

Javax.servlet,http packages
Javax.servlet,http packagesJavax.servlet,http packages
Javax.servlet,http packagesvamsi krishna
 
Web Tech Java Servlet Update1
Web Tech   Java Servlet Update1Web Tech   Java Servlet Update1
Web Tech Java Servlet Update1vikram singh
 
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
 
Core web application development
Core web application developmentCore web application development
Core web application developmentBahaa Farouk
 
java Servlet technology
java Servlet technologyjava Servlet technology
java Servlet technologyTanmoy Barman
 
java servlet and servlet programming
java servlet and servlet programmingjava servlet and servlet programming
java servlet and servlet programmingKumar
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postvamsi krishna
 
Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jspJafar Nesargi
 
An Introduction To Java Web Technology
An Introduction To Java Web TechnologyAn Introduction To Java Web Technology
An Introduction To Java Web Technologyvikram singh
 
J2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsJ2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsKaml Sah
 
Java servlets
Java servletsJava servlets
Java servletslopjuan
 
Servlet and JSP
Servlet and JSPServlet and JSP
Servlet and JSPGary Yeh
 
Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course JavaEE Trainers
 

What's hot (20)

Javax.servlet,http packages
Javax.servlet,http packagesJavax.servlet,http packages
Javax.servlet,http packages
 
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
 
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
 
Core web application development
Core web application developmentCore web application development
Core web application development
 
java Servlet technology
java Servlet technologyjava Servlet technology
java Servlet technology
 
java servlet and servlet programming
java servlet and servlet programmingjava servlet and servlet programming
java servlet and servlet programming
 
Servletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
 
Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jsp
 
Jsp servlets
Jsp servletsJsp servlets
Jsp servlets
 
Servlets
ServletsServlets
Servlets
 
An Introduction To Java Web Technology
An Introduction To Java Web TechnologyAn Introduction To Java Web Technology
An Introduction To Java Web Technology
 
J2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsJ2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - Components
 
JDBC
JDBCJDBC
JDBC
 
Java servlets
Java servletsJava servlets
Java servlets
 
Servlet and JSP
Servlet and JSPServlet and JSP
Servlet and JSP
 
Servlets
ServletsServlets
Servlets
 
Servlets
ServletsServlets
Servlets
 
JAVA Servlets
JAVA ServletsJAVA Servlets
JAVA Servlets
 
Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course
 

Viewers also liked

Do We Need Containers Anyway?
Do We Need Containers Anyway?Do We Need Containers Anyway?
Do We Need Containers Anyway?Dmitry Buzdin
 
Dynamic content generation
Dynamic content generationDynamic content generation
Dynamic content generationEleonora Ciceri
 
Java Servlets
Java ServletsJava Servlets
Java ServletsEmprovise
 
Database Architecture and Basic Concepts
Database Architecture and Basic ConceptsDatabase Architecture and Basic Concepts
Database Architecture and Basic ConceptsTony Wong
 
Introduction to HTTP protocol
Introduction to HTTP protocolIntroduction to HTTP protocol
Introduction to HTTP protocolAviran Mordo
 
Relational Database Design - Lecture 4 - Introduction to Databases (1007156ANR)
Relational Database Design - Lecture 4 - Introduction to Databases (1007156ANR)Relational Database Design - Lecture 4 - Introduction to Databases (1007156ANR)
Relational Database Design - Lecture 4 - Introduction to Databases (1007156ANR)Beat Signer
 
Introduction to Web Architecture
Introduction to Web ArchitectureIntroduction to Web Architecture
Introduction to Web ArchitectureChamnap Chhorn
 

Viewers also liked (13)

Do We Need Containers Anyway?
Do We Need Containers Anyway?Do We Need Containers Anyway?
Do We Need Containers Anyway?
 
Dynamic content generation
Dynamic content generationDynamic content generation
Dynamic content generation
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Java
JavaJava
Java
 
Containers for Non-Developers
Containers for Non-DevelopersContainers for Non-Developers
Containers for Non-Developers
 
Chapter2 Encapsulation (Java)
Chapter2 Encapsulation (Java)Chapter2 Encapsulation (Java)
Chapter2 Encapsulation (Java)
 
Java awt
Java awtJava awt
Java awt
 
Encapsulation
EncapsulationEncapsulation
Encapsulation
 
Database Architecture and Basic Concepts
Database Architecture and Basic ConceptsDatabase Architecture and Basic Concepts
Database Architecture and Basic Concepts
 
Introduction to HTTP protocol
Introduction to HTTP protocolIntroduction to HTTP protocol
Introduction to HTTP protocol
 
Awt
AwtAwt
Awt
 
Relational Database Design - Lecture 4 - Introduction to Databases (1007156ANR)
Relational Database Design - Lecture 4 - Introduction to Databases (1007156ANR)Relational Database Design - Lecture 4 - Introduction to Databases (1007156ANR)
Relational Database Design - Lecture 4 - Introduction to Databases (1007156ANR)
 
Introduction to Web Architecture
Introduction to Web ArchitectureIntroduction to Web Architecture
Introduction to Web Architecture
 

Similar to Java EE 01-Servlets and Containers

Ppt for Online music store
Ppt for Online music storePpt for Online music store
Ppt for Online music storeADEEBANADEEM
 
Jsp and Servlets
Jsp and ServletsJsp and Servlets
Jsp and ServletsRaghu nath
 
Servlet viva questions
Servlet viva questionsServlet viva questions
Servlet viva questionsVipul Naik
 
JEE Course - The Web Tier
JEE Course - The Web TierJEE Course - The Web Tier
JEE Course - The Web Tierodedns
 
SERVER SIDE PROGRAMMING
SERVER SIDE PROGRAMMINGSERVER SIDE PROGRAMMING
SERVER SIDE PROGRAMMINGPrabu U
 
Difference between Servlet and JSP.docx
Difference between Servlet and JSP.docxDifference between Servlet and JSP.docx
Difference between Servlet and JSP.docxDr. Somnath Sinha
 
Liit tyit sem 5 enterprise java unit 1 notes 2018
Liit tyit sem 5 enterprise java  unit 1 notes 2018 Liit tyit sem 5 enterprise java  unit 1 notes 2018
Liit tyit sem 5 enterprise java unit 1 notes 2018 tanujaparihar
 
WEB TECHNOLOGY Unit-3.pptx
WEB TECHNOLOGY Unit-3.pptxWEB TECHNOLOGY Unit-3.pptx
WEB TECHNOLOGY Unit-3.pptxkarthiksmart21
 
Java Servlet
Java ServletJava Servlet
Java ServletYoga Raja
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
 Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1... Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...WebStackAcademy
 
Session 26 - Servlets Part 2
Session 26 - Servlets Part 2Session 26 - Servlets Part 2
Session 26 - Servlets Part 2PawanMM
 
Servlet in java , java servlet , servlet servlet and CGI, API
Servlet in java , java servlet , servlet servlet and CGI, APIServlet in java , java servlet , servlet servlet and CGI, API
Servlet in java , java servlet , servlet servlet and CGI, APIPRIYADARSINISK
 
UNIT-3 Servlet
UNIT-3 ServletUNIT-3 Servlet
UNIT-3 Servletssbd6985
 

Similar to Java EE 01-Servlets and Containers (20)

Ppt for Online music store
Ppt for Online music storePpt for Online music store
Ppt for Online music store
 
Jsp and Servlets
Jsp and ServletsJsp and Servlets
Jsp and Servlets
 
Servlet viva questions
Servlet viva questionsServlet viva questions
Servlet viva questions
 
JEE Course - The Web Tier
JEE Course - The Web TierJEE Course - The Web Tier
JEE Course - The Web Tier
 
SERVER SIDE PROGRAMMING
SERVER SIDE PROGRAMMINGSERVER SIDE PROGRAMMING
SERVER SIDE PROGRAMMING
 
Difference between Servlet and JSP.docx
Difference between Servlet and JSP.docxDifference between Servlet and JSP.docx
Difference between Servlet and JSP.docx
 
Liit tyit sem 5 enterprise java unit 1 notes 2018
Liit tyit sem 5 enterprise java  unit 1 notes 2018 Liit tyit sem 5 enterprise java  unit 1 notes 2018
Liit tyit sem 5 enterprise java unit 1 notes 2018
 
WEB TECHNOLOGY Unit-3.pptx
WEB TECHNOLOGY Unit-3.pptxWEB TECHNOLOGY Unit-3.pptx
WEB TECHNOLOGY Unit-3.pptx
 
Weblogic
WeblogicWeblogic
Weblogic
 
Java Servlet
Java ServletJava Servlet
Java Servlet
 
J servlets
J servletsJ servlets
J servlets
 
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
 Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1... Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
Web Component Development Using Servlet & JSP Technologies (EE6) - Chapter 1...
 
Marata
MarataMarata
Marata
 
Servlet classnotes
Servlet classnotesServlet classnotes
Servlet classnotes
 
Servlets
ServletsServlets
Servlets
 
Session 26 - Servlets Part 2
Session 26 - Servlets Part 2Session 26 - Servlets Part 2
Session 26 - Servlets Part 2
 
Servlets api overview
Servlets api overviewServlets api overview
Servlets api overview
 
Servlet in java , java servlet , servlet servlet and CGI, API
Servlet in java , java servlet , servlet servlet and CGI, APIServlet in java , java servlet , servlet servlet and CGI, API
Servlet in java , java servlet , servlet servlet and CGI, API
 
UNIT-3 Servlet
UNIT-3 ServletUNIT-3 Servlet
UNIT-3 Servlet
 
Wt unit 3
Wt unit 3 Wt unit 3
Wt unit 3
 

Recently uploaded

Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 

Recently uploaded (20)

9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 

Java EE 01-Servlets and Containers

  • 1. Introduction to Java Enterprise Edition ● First steps with Servlet Technology. Servlet Container & Application Server ● Fernando Gil Fernando Gil lobho.gil@gmail.com lobho.gil@gmail.com Marzo 2012 Marzo 2012
  • 2. Introduction ● The goal of this course is to explain you how can you start to develop Java EE applications. ● We will accomplished our goals by presenting the theory behind the concepts of Servlets and JavaServer Pages. ● Using JBoss AS or similar we'll present practical exercises to support all the knowledge obtained.
  • 3. A Servlet is... ● A server-side entity. ● A Java programming language class used to extend the capabilities of servers that host applications access via a request-response programming model. ● The Java counterpart to non-Java dynamic Web content technologies such as CGI and ASP.NET.
  • 4. Server Responsibilities ● Every server has two main responsibilities: ● Handle Client Requests. ● Create a response to the clients. In the case of HTTP servers that host web applications this could be a difficult task because they need to create dynamic web contents, which may include complicated tasks such as retrieving information from the database, apply business rules and present the information in specific views. The best way to perform this responsibility is create server extensions that we know as Servlets.
  • 5. Servlet Container ● To deploy and run a servlet, a Web server uses a separate module. This specialized module is called Web container or servlet container and is responsible for managing the lifecycle of servlets, mapping a URL to a particular servlet and ensuring that the URL requester has the correct access rights. ● The next picture shows how different components fit together. The file system stores HTML files, the Servlet container execute the Servlets, and business data is in the database. The Web browser sends requests to the Web server. If the target is an HTML file, the server handles it directly but If the target is a servlet then the server delegates the request to the servlet container, once there, the servlet can use the file system and database to generate dynamic output.
  • 7. Servlet container types Conceptually, a servlet container is a part of the web server, even though it may run in a separate process. We can classify the servlet container in three types: ● Standalone: Are typically Java-based servers where the servlet container and the web server are integral part of a single program. One common example is Tomcat running by itself. ● In-process: The servlet container is separated from the web server, because is a different program, but runs within the address space of the main server as a plug-in. One example is Tomcat running inside JBoss. ● Out-of-process: The servlet container and the web server are different programs and both run in a different process. To perform communications between them, the web server uses a plug-in usually provided by the servlet container vendor.
  • 8.
  • 9. Relationship between Servlet Container & Servlet API ● Java's Servlet specification provides a standard and platform-independent framework for communication between servlets and their containers. All the servlet containers must provide this API. ● This framework is made up of a set of interfaces an classes which are collectively called the Servlet Application Programming Interfaces. ● The Servlet API is divided into two packages: javax.servlet and javax.servlet.http
  • 10. javax.servlet ● This package contains the generic interfaces and classes that are independent of any protocol. Name Brief Description Servlet interface This is the central interface in the API. Every class must directly or indirectly implements this interface. GenericServlet It is an abstract class that provides implementation class for all the methods except the service() method of the Servlet interface ServletRequest Provides a generic view of the request that was sent interface by a client and defines methods that extract information form the request. ServletResponse Provides a generic way of sending responses to the interface client.
  • 11. javax.servlet.http ● This package contains the basic functionality required for HTTP servlets. Interfaces an classes in this package extend the corresponding interfaces an classes of the javax.servlet package. Name Brief Description HttpServlet class Is an abstract class that extends GenericSevlet. It adds a new service() method. HttpServletRequest Extends ServletRequest and provides an HTTP- interface specific view of the request. It defines methods that extract information such as HTTP headers an cookies from the request. HttpServletResponse Extends ServletResponse and provides an HTTP- interface specific way of sending responses. It defines methods that assist in setting information, such as HTTP headers and cookies into the response.
  • 12. Advantages of the Servlet API Advantage Description Flexibility If we need to extend the server functionality all we have to do is write a new servlet specific for that requirement without modifying the server itself. Separation of The server only needs to worry about responsibilities network and communication, while the servlet interprets and response to every client request. Java language Java programmers do not need to lear a new language. Portability We can write a servlet in one container, and deploy it in another.
  • 13. Disadvantages of the Servlet API ● One disadvantage, rather restriction is that you have to stick to the rules set for the framework to make the container happy. ● Theoretically using the API you can write servlets for almost any kind of protocol but, by the moment, the Servlet specification only demands support to HTTP.