Q-3 Get & Post what are they? ~ MY Thoughts & Learnings

Sunday, July 19, 2009

Q-3 Get & Post what are they?

Both are the methods of the HTTP protocol.Whenever client wants to access a resource from the server the web browser generates a HTTP Request.This request can either be in get or post method.Get is used to pass limited and insensitive/non-personal/insecure data to the server.Data sent through this is visibleto the client.Whereas Post is much more powerful technique where large amount of data can be sent & still client is unable to see that data.Post is generally used for username,password,credit card number etc which are personal and sensitive data that needs to be hidden.

GET EXAMPLE

http://www.google.co.in/search?hl=en&q=java&meta=&aq=f&oq

http:// is the protocol used.

http://www.google.co.in is the host/server/container URL.

/search is the path to the resource on the server

?hl=en&q=java&meta=&aq=f&oq= after the ? are the parameters sent to the server in this GET Request.For example - hl=en means that language is English. & is used to separate two parameters. Along with this Request header is also sent which has details such as User-Agent,Accept,Accept-Language,Keep-Alive etc.Giving General information about the client.

Whereas in post method -
1. Is much more Powerful than get method
2. Any amount of data can be sent.
3. Client is not able to see the data sent to the request thus protecting the personal/secured data from being viewed by anybody.

Remember : doGet() is the default method of the servlet and is automatically executed when the servlet/JSP page is run for the first time.


0 comments: