Quick Introduction

Back Up Next

 

Quick Introduction
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
The ServletRequest interface allows the servlet access to:
Information such as the names of the parameters passed in by the client, the protocol (scheme) being used by the client, and the names of the remote host that made the request and the server that received it. 
The input stream, ServletInputStream. Servlets use the input stream to get data from clients that use application protocols such as the HTTP POST and PUT methods.

Interfaces that extend ServletRequest interface allow the servlet to retrieve more protocol-specific data. For example, the HttpServletRequestinterface contains methods for accessing HTTP-specific header information.

 The ServletResponse interface gives the servlet methods for replying to the client. It:
Allows the servlet to set the content length and MIME type of the reply 
Provides an output stream, ServletOutputStream, and a Writer through which the servlet can send the reply data

Interfaces that extend the ServletResponse interface give the servlet more protocol-specific capabilities. For example, the HttpServletResponseinterface contains methods that allow the servlet to manipulate HTTP-specific header information