Http request and http response

13
HTTP REQUEST AND HTTP RESPONSE BY SANA MATEEN

Transcript of Http request and http response

Page 1: Http request and http response

HTTP REQUEST AND HTTP RESPONSE

BYSANA MATEEN

Page 2: Http request and http response

HTTP REQUEST

• HTTP (Hypertext Transfer Protocol) is perhaps the most popular application protocol used in the Internet (or The WEB).

• HTTP is a stateless protocol. In other words, the current request does not know what has been done in the previous requests.

• Whenever you issue URL from your browser to get a web resource using HTTP, the browser turns the URL into a request message and sends it to the HTTP server. The HTTP server interprets the request message, and returns you an appropriate response message, which is either the resource you requested or an error message.

Page 3: Http request and http response

Important header informationAccept This header specifies the MIME types that the browser or other

clients can handle. Values of image/png or image/jpeg are the two most common possibilities.

Authorization This header is used by clients to identify themselves when accessing password-protected Web pages.

Content-Length This header is applicable only to POST requests and gives the size of the POST data in bytes.

Methods to read HTTP Header:There are following methods which can be used to read HTTP header in your servlet program. These methods are available with HttpServletRequest object.Enumeration getHeaderNames()Returns an enumeration of all the header names this request containsString getHeader(String name)Returns the value of the specified request header as a String.

Page 4: Http request and http response
Page 5: Http request and http response
Page 6: Http request and http response

HTTP GET REQUEST

Page 7: Http request and http response
Page 8: Http request and http response
Page 9: Http request and http response

HTTP POST REQUEST

Page 10: Http request and http response
Page 11: Http request and http response
Page 12: Http request and http response
Page 13: Http request and http response