J2ee web fundamentals lesson 4 request and response
This presentation is the property of its rightful owner.
Sponsored Links
1 / 27

J2EE Web Fundamentals Lesson 4 Request and Response PowerPoint PPT Presentation


  • 90 Views
  • Uploaded on
  • Presentation posted in: General

J2EE Web Fundamentals Lesson 4 Request and Response. Instructor: Dr. Segun Adekile. Outline. Objectives Course Text Book Basham, Bryan; Sierra, Kathy; Bates, Bert (2012-10-30). Head First Servlets and JSP (Kindle Location 1349). O'Reilly Media. Kindle Edition. Request and Response

Download Presentation

J2EE Web Fundamentals Lesson 4 Request and Response

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


J2ee web fundamentals lesson 4 request and response

J2EE Web FundamentalsLesson 4Request and Response

Instructor: Dr. Segun Adekile


Outline

Outline

  • Objectives

  • Course Text Book

    • Basham, Bryan; Sierra, Kathy; Bates, Bert (2012-10-30). Head First Servlets and JSP (Kindle Location 1349). O'Reilly Media. Kindle Edition.

  • Request and Response

    • Being a Servlet


Objectives

Objectives


Agenda

Agenda

  • How the Container Handles a Request

  • Servlet Lifecycle

    • Loading

    • Initialization

    • Service

      • HTTP Methods

      • Request Object

      • Response Object

  • Response Redirect

  • Request Dispatch


How the container handles a request

How the Container Handles a Request


How the container handles a request1

How the Container Handles a Request


How the container handles a request2

How the Container Handles a Request


Servlet lifecycle

Servlet Lifecycle

  • The servlet lifecycle is simple

  • There is only one main state – initialized

  • If the servlet isn’t initialized, then it’s either

    being initialized (running its constructor or

    init() method), being destroyed (running its

    destroy() method), or it simply does not exist


Servlet lifecycle1

Servlet Lifecycle


Servlet lifecycle2

Servlet Lifecycle


Servlet lifecycle3

Servlet Lifecycle


Servlet loading

Servlet Loading

  • When the Container starts, it looks for deployed web apps and then starts searching for servlet class files

    • Findingthe class is the first step

    • Loading the class is the second step, and it happens either on Container startupor first client use. Your Container might give you a choice about class loading, or it might load the class whenever it wants.


Servlet initialization

Servlet Initialization

  • The constructor makes only an object

  • To be a servlet, the object needs to be granted servletness, getting all the unique

    privileges that come with being a servlet e.g. its ServletContextreference.

  • You can override the init() method to add

    operations such as getting a db connection or

    registering yourself with other objects.


Servlet initialization1

Servlet Initialization


Servlet service request and response

Servlet Service: Request and Response


Servlet service http methods

Servlet Service - HTTP Methods


Servlet service http methods1

Servlet Service - HTTP Methods

  • Intended use:

  • for getting things

  • Idempotent

  • Intended use:

  • for sending data to be processed

  • Non-idempotent


Servlet service http methods2

Servlet Service - HTTP Methods


Sending and using a single parameter

Sending and using a single parameter

getParameterValues – for multiple values


Servlet service request object

Servlet Service – Request Object


Lifecycle key points

Lifecycle key points


Httpservletrequest key points

HTTPServletRequest key points


Servlet service response object

Servlet Service – Response Object

  • The response is what goes back to the client.

  • It is parsed and rendered by the browser.

  • Typically the response object is used to get an

  • output stream which is used to write the HTML,

    which goes back to the client.


Response redirect

Response Redirect


Response redirect1

Response Redirect


Request dispatch

Request Dispatch


Httpservletresponse key points

HTTPServletResponsekey points


  • Login