Sunday, September 15, 2013

Difference Between Get and Post


Difference between http Get and post request:-
Conventionaly get request is used for requesting static contents and post request is used for requesting dynamic contents.

Technical Dofference:-
11.     In case of get request, request data is sent as part of header. Size of http packet header is fixed hence only limited amount of data can be send as part of get request. In case of post request, request data is sent as part of body. Size of http packet body can be unlimited and unlimited amount of data can be send as part of post request.

22.      In case of get request, request data is displayed in the address bar of browser. Where as Incase of post request it is not displayed in the address bar.

33.      In case of get request, request data is transmited over the network has submited user. Where as In case of post request, request data is first incripted using the 32 bit data incription and then transmited the data on network.

44.      Get request is idempotent where as post is not.

javax.servlet.http package


Javax.servlet.http package provides http specific classes and Interfaces of servlet API. Commonaly used members of this package are:-
1.      HttpServletRequest:-  This Inetrface extends ServletRequest and adds http specific methods.
2.      HttpServletResponse:-  This Interface extends ServletResponse and adds http specific methods.
3.      HttpServlet:- It is a helper class with extends GenericServlet and provides methods for each http specific method is used super class.

doGet() and doPost() are two commonly used methods.
They are use to process http get and post process respectively.
public void doGet(HttpServletRequest request,HttpServletResponse response);
public void doPost(HttpServletRequest request,HttpServletResponse response);
public void doPut(HttpServletRequest request,HttpServletResponse response);
public void doDelete (HttpServletRequest request,HttpServletResponse response);
public void doHead (HttpServletRequest request,HttpServletResponse response);
public void doTrace(HttpServletRequest request,HttpServletResponse response);
public void doOptions(HttpServletRequest request,HttpServletResponse response);
public void doConnect(HttpServletRequest request,HttpServletResponse response);


Request passing by Http protocol


There are 8 types of request passing by the http protocol.

Http protocol is used to request content from the server. Http protocol support following types of request.

1.    Get
2.    Post
Note: Get and Post are used to request  contents from the server.

3.    Put
4.    Delete
5.    Haed
6.    Trace
7.    Options
8.    Connect
Note:  These are used for connection setup and management.