JSP Client Request & Server Response

JSP Client Request

  • When a browser requests a web page it sends lots of information to the web server along with the request.
  • The request information travels as a part of HTTP header.
  • The request object is an instance of a javax.servlet.http.HttpServletRequest object.

Request Header

Following are some of the common headers sent along with request.

AcceptThis header specifies the MIME type that the browser or other clients can handle.
Accept-Charset It specifies the character sets that browser can use to display information.
Accept-EncodingIt specifies the type of encoding that the browser can handle.
AuthorizationUsed in password protected web pages to identify themselves.
ConnectionThe persistent connections permit the client or other browser to retrieve multiple files.
CookieReturns the cookies of the server that were previously sent to the browser.
HostSpecifies the host and port as given in original URL.

JSP Server Response

  • The JSP provides the technique to access a web server HTTP response to the browser.
  • The response typically consists of a status line, some response headers and documents.
  • The response object is an instance of a javax.servlet.http.HttpServletResponse object.

Response Header

Following are some common headers which go back to the browser from website.

AllowSpecifies the request methods (GET, POST) that server supports.
ConnectionIt instructs to use HTTP connections persistently.
Content-EncodingSpecifies the way in which the page was encoded during transmission.
Content-LanguageSpecifies the language in which the document is written. E.g. en, en-us etc.
Content-TypeSpecifies the MIME type of the response document.
Content-LengthSpecifies the number of bytes in response.
ExpiresSpecifies the expiry time for the content.
RefreshSpecifies the time in second in which pages would be refreshed.