Pages

Tuesday, June 12, 2012

HTTP the logic behind the web

HTTP
Stands for hypertext transfer protocol uses port no-80
used for communication between a Browser (client) and web servers.
HTTP is stateless protocol:stateless means it doesn't keep track of requests that have been processed or we can say HTTP cant recognize clients,if the same browser is making requests it will not be able to relate them in anyway.
HTTP processes requests and forget about them.
The communication between client and server happens in the form of
  • Request.
  • Response.

Request : is a request message sent by Browser of end user to the server, this request contains following information:

  1. Method of request(get/post).
  2. Browser and Operating system information.
  3. Query parameters.
  4. server address.
  5. URI(uniform resource identifier).
  6. Protocol used for sending request(http).
  7. Port no. used for request.
  8. Security enable/disable information.
  9. cookies.
  10. and many other
example : http://www.ctrl-f9.com/login.jsp?name="hemant"&pass="123456"

Above example is a     http request    for server    "www.ctrl+f9.com"    for a jsp page named     login.jsp   with two query attributes   name=hemant   and   pass=123456.

Response: Response is to be provided by the web server on the other side.the response may be a simple HTML document or execution of a process,the result of which is then appended to the response.

>> response is to be produced according to the request,where the  request can be a static page,accessing database or updating some database records or some other type.
>> server uses the same port for sending response back to the client which was used by client to send the request. i.e   a http request will always get a http response.
>> if response contains a html document which further contains some images or videos or some other data like shown in the example below:
<html>
<head>
<title>example</title>
</head>
<body>
<img src="http://www.ctrl-f9.com/images/hsd.jpg" width="200" height="100"/>
<embed src="http://www.ctrl-f9.com/videos/mysong.mpeg" width="200" height="100"/>
</body>
</html>
 then, the image and video which is embedded in the page will be accessed separately with separate requests for each image or  video.
so we can say the html page will be loaded first then the other elements like images and audio video.

Request/response Methods :

1. Get:-

>> this method is most commonly and by default used to request static pages or the requests which don't require any processing from the server.
>> there is no problem if we refresh or request the same page/resources again in the same session.
>> uses URL to append request parameters, and don't use any separate message body for the request parameters.

2. Post:-

>> is most commonly used to transfer form data from client to server for performing some database transaction or some other processing with the form data.
>> uses a separate message body to send request parameters,it don't use URLs to append request parameters contrary to : http://www.ctrl+f9.com/login.jsp?name="hemant"&pass="123456" 
>> Refreshing the page or resending the page requests for pages with html forms can cause troubles sometime,so we use POST method.
POST method always alerts the end user before resending the form data. 


No comments:

Post a Comment