Different Actors in Web application
There are different actors which comes into picture of web application.
- End User
- Web Client(Browser Application)
- Server(Web Server / Application Server)
- Actual Page requested on Server
User : It’s the end user who actually raise the request for a page on Server or submit a form.
Web Client : Browsers(IE, Firefox..) are software that knows how to communicate with servers using HTTP protocol and render the page recieved from server in the form of HTML.
Server : Servers are kind of software which handle the user request and search for the content requested by end User and return the appropriate result(Requested Page or Error Code). Server can be of two type web server and App Server. It’s web server which directly handles the user request and pass it to app server to process.
What is HTML
HTML(Hyper text markup Language) is a language used by servers to send the response to Browser’s so that they(Browsers) can render the page properly on user side.
What is HTTP Protocol
HTTP(Hyper Text Transfer Protocol) is protocol used by client(Browser) and server(Web Server) to communicate. HTTP has web specific featured that runs on TCP/IP protocol. Structure of HTTP conversation can be divided in two types, HTTP Request or HTTP Response.
Note*: HTML can be the part of HTTP protocol response.
When ever end User clicks any link or submit any form browser send HTTP Request to Server so that server can process it and provide the HTTP Response.
HTTP Request’s are of different kind. HTTP has several methods which inform the server about the kind of Request is being made by browser.
Methods in HTTP Protocol
GET method is the default method which will be used by Browser(If not specified explicitly). GET method is used by browser to ask(Not submitting any data) for some kind of resources on server(HTML, Image, PDF etc..).
POST method is used by browser to send some information to server for processing. Eg. Form Submission..
HTTP Request Example
Host =javabeginnerstutorial.com User-Agent =Mozilla/5.0 (Windows NT 6.0; rv:15.0) Gecko/20100101 Firefox/15.0.1 Accept =text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language =en-gb,en;q=0.5 Accept-Encoding =gzip, deflate Connection =keep-alive Cookie =****Deleted Date ********* If-None-Match =****Deleted Date *********
Difference between GET and POST method
GET method used for asking some data from server. While POST is used for submission some data to server.
GET is idempotent while POST is not idempotent.
GET do not have any BODY part while POST has.
GET can submit some data but that will be the part of Header and there is limitation on data submitted via GET method while Post can submit data in body part and there is no restriction on data that can be submitted in POST request.
This is what server send to user client(Browser) when user ask for something from Server(GET / POST Request). HTTP Response contains Header and a Body part.
HTTP Response Header Contains below information along with others
- Protocol Version(Used by web server)
- HTTP Status Code(Successful/Fail/Not Found….)
- Content Type (MIME Type)
- Content Length
- Server details
Content Type(content-type) in header part of HTTP response is also known as MIME type. This information is used to tell the browser the kind of data server is sending, weather it is Image or Text or PDF or anything else. According to this information Browser will know how to handle the data.
HTTP Response, Body part contains the HTML or other content that needs to be rendered by Browser on client side.
HTTP Response Example
Status =OK - 200 Date =Sun, 07 Oct 2012 18:00:32 GMT Server =Apache X-Pingback =https://javabeginnerstutorial.com/ Vary =Accept-Encoding,Cookie,User-Agent Expires =Sun, 07 Oct 2012 19:00:33 GMT Pragma =public Cache-Control =max-age=3600, public, must-revalidate, proxy-revalidate Etag =89aba25474c721198ed96b924c270932 X-Powered-By =W3 Total Cache/0.9.2.4 Content-Encoding =gzip Set-Cookie =PHPSESSID=3ccad49ae7e632de2f908b8ba36e70a5; path=/ Last-Modified =Sun, 07 Oct 2012 18:00:33 GMT Content-Type =text/html; charset=UTF-8 X-Cache =*****************Deleted Data*************** X-Cache-Lookup =*****************Deleted Data*************** Via =*****************Deleted Data*************** Connection =close
- HTTP protocol is used in the web and it runs over TCP/IP protocol.
- Browser makes a HTTP request when it require anything from server and server will send HTTP Response back to browser.
- MIME-Type in HTTP Response tell browser the kind of data server is sending and browser uses this is data to figure out how to handle it.
- HTTP Request have different type of method like GET, PUT, DELETE, OPTION, TRACE. In web application mainly GET and POST method is used.
- GET method is used to ask for data from server while POST method is used to submit data to server.
- GET method can also send data to server but in that case data will be appended to the end of URL.
- POST method append data in the body of the request.
- URL stands for Uniform Resource Locator, Every resource on the web has unique URL.