Show TOC Start of Content Area

Background documentation Servicing Client Requests  Locate the document in its SAP Library structure

Use

The actual processing of client requests takes place in the service method of the servlet (or some of the doGet, doPost and so on, in case of an HttpServlet type of servlet). The service method is always passed a request object and a response object as parameters. The logic of this method is to retrieve information about the request and the Web client using the request object, if necessary accessing external resources to generate data for the response, and then to construct a response by modifying the response object or writing directly into the response stream.

Prerequisites

To execute in its service method, a servlet must be successfully loaded, instantiated and initialized by the Web Container.

Features

The Request Object

This object contains all the information about the client request. When you develop servlet you may have to:

      Use the methods of the request object to retrieve information about the HTTP request (for example, headers, parameters, connection type) and the client (that is, the user that has made the request).

      Retrieve the client input – using either the InputStream, or the input reader, you can get and parse additional data sent by the client as HTTP body.

      Retrieve HTTP parameters that are included in the request in the order in which they are included, and so on.

The Response Object

This object contains all the information about the response that will be generated for the client request. You must know:

      The correct order to fill in the headers and body of the response.

      Which methods are available to the response object – which response parameters you can configure, as well as what their values should be.

      How to use persistent connections to optimize performance.

      How to send the response using either OutputStream, or PrintWriter objects.

 

End of Content Area