Skip to main content

Http request and Http response

HTTP Structure

HTTP Contain HTTP Header and HTTP Body separated by single empty line http-structure

Key Element of HTTP request

  • URL
  • Form data
  • HTTP method( if present)
  • Cookies

URL

  • Every web resources must have its unique address in form of web URL.
  • URL present in Header part of HTTP request.

Form data

  • Data collected using HTML form is called form data and in HTTP request its optional information
  • If it is present then it will be present in header or body part of the HTTP request depending on the HTTP method present in the request.

HTTP method

  • It indicates desired action to be performed on dynamic web resources
  • HTTP has a different method and In Servlet we implement that method based on action to be performed.
  • This all Default implementation of method present in Servlet API  javax.servelet.httpservlet

http-method

Key Element of HTTP response

  • Status code
  • Content type
  • Actual content
  • Cookies( if present)

Status code

  • Status code represent status of HTTP request
  • It is mandatory information and it will be present in Header part of HTTP response.

status-code

Content Type

  • Content type tells the browser what type of content its going to receive so that it can prepare itself to handle response data
  • Exa. make use of adobe plugin to handle pdf file.
  • It is mandatory information and it is present in header part of HTTP request.

List of Content Type

  1. Text/html
  2. application/pdf
  3. video/quicktime
  4. image/jpeg
  5. application/x-zip