Engineering Full Stack Apps with Java and JavaScript
There are four main entities involved in the HTTP request-response model:
We will learn about request and response here.
Container provides us with two objects corresponding to request and response, encapsulating the request details and an empty response object when a request is received. These object interfaces also contain many convenience methods. These are passed through the service method of the servlet, which will then pass to us through the doXXX methods.
Interfaces for request and response objects
Two important interfaces related to request are:
javax.servlet.ServletRequest
Is protocol independent
javax.servlet.http.HttpServletRequest
Is specific to an HTTP protocol.
HttpServletRequest extends ServletRequest
Provides additional useful methods related HTTP requests.
Two important interfaces related to response are:
javax.servlet.ServletResponse
Is protocol independent.
javax.servlet.http.HttpServletResponse
Is specific to an HTTP protocol.
HttpServletResponse extends ServletResponse.
Additional convenience methods provide support for:
Cookie manipulation .
HTTP headers and status codes
URL rewriting used for session management
Request Attributes and Parameters
Request attributes are only visible between components involved in the current request, and are destroyed once the request is fulfilled and response is sent. They are stored in ServletRequest implementation object.
Request parameters are info sent from client apart from standard protocol headers and are read-only from the application. In HTTP, parameters are sent through the URL in the query string (GET) or in the request body (POST).
Read more @ http://javajee.com/parameters-and-attributes-in-servlet