1 of 10

Advanced java programming

Introduction to Servlets

M.Jeevana sujitha

Assistant Professor

Department of Computer Science and Engineering

SRKR Engineering College, Bhimavaram, A.P. - 534204

2 of 10

OBJECTIVES

The Objectives of this lecture are

  • To learn about http request response model.
  • To learn about what is servlet and uses of servlets.

3 of 10

Introduction to Servlets

Http Request-Response Model:

4 of 10

Introduction to Servlets

Http Request-Response Model:

  • HTTP is a stateless request response based communication protocol.
  • It is used to send and receive data on the web.
  • It uses a reliable TCP connection either for the transfer data to and from clients which was web browsers.

5 of 10

Introduction to Servlets

Http Request-Response Model:

  • The client will initiate the communication by sending a request (normally called as an HTTP request).
  • The HTTP Server or web server takes the request from the client and processing the request and

then sends a response (normally called as an HTTP response).

  • Every time a client needs to sends the request, it first establishes a reliable TCP connection with the

web server and then transfer the request via that connection.

  • The same happens in case a web server needs to send back an Http response to a client.

6 of 10

Introduction to Servlets

HTTP Request

  • Key element of request

stream.

  • HTTP method GET or POST (action to be performed)
  • The page to

(URL)

  • Form parameters.

Http Response

  • Key element of response

stream.

  • A status code (for whether the request was successful or not)
  • Content type (text,

picture, html)

  • The content (actual

content)

access

7 of 10

Introduction to Servlets

Need of servlet:

  • Suppose the client needs a dynamic web page, but the server does not handle dynamic web pages. It can handle only static web pages.
  • So in order to satisfies the client request for dynamic web pages, the servlet came into picture.

8 of 10

Introduction to Servlets

What is servlet?

  • Servlets are simple java programs that run on the servers. Hence the name servlets came into picture.
  • Servlets are most commonly used with HTTP hence sometimes servlets are also called as HTTP-Servlet.
  • Servlets make use of the java standard extension classes in the packages javax.servlet and javax.servlet.http

9 of 10

Introduction to Servlets

Uses of Servlets:

  • Servlets can process and store the data submitted by an HTML form.
  • Servlets are useful for providing the dynamic contents. For example retrieving and updating the data bases.
  • Servelts can be used in the cookies and session tracking.

10 of 10

THANK YOU