Professional Documents
Culture Documents
1. Interaction between
Client and Server
Basis of operation Web server provides Web pages for clients i.e.
browsers
Client-Server interaction.
More later
HTTP in more detail
GET method
Used to request a Web page from a specified server
or
Used to submit user data (small amount) to a server.
POST method
Used to submit user data (large amount) to a server.
GET and POST are two methods defined in HTTP that work in
different ways, but both are able to send data, e.g. HTML form
submissions, to the server.
GET is what a browser uses for most files, like Web pages.
GET may also be used for some Web form submissions to the
server, if there is not too much data. E.g. a Google search request.
Normally, the HTTP POST method is used to send a block
of data to the server to be processed
- Whatever that may entail, e.g. updating a database.
Request
Response
Request
GET /index.html
HTTP/1.0
HTTP/1.0 200 OK
"Welcome to our
Web site!"
Response
The basic format of an HTTP request/response message
is
A blank line
E.g.
E.g.
HTTP/1.0 200 OK
E.g.
Content-Type: text/html
For multimedia objects in the Web page, e.g. images, further GETs
have to issued by the browser
Content-Type: image/gif
GET / HTTP/1.0
Host: www.abc.com
Accept: image/gif, image/jpeg, */*
Accept-Language: en
User-Agent: "Mozilla/5.0 (Windows NT 10.0; Gecko/20100101
Firefox/54.0"
Connection: Keep-Alive
HTTP/1.0 200 OK
Date: Mon, 14 August 2017 16:20:42 GMT
Server: Apache/2.2.15 (Scientific Linux)
Connection: keep-alive
Content-Type: text/html Headers
Last-Modified: Wed, 20 Jan 2016 17:39:05 GMT
Content-Length: 2543
The user enters data into a Web form, then clicks a Submit
button on the form.
More later
Using Web Forms for sending data to the server
<html>
<body>
<form action="script" method="GET"|"POST">
... // HTML form elements
</form>
</body>
</html>
Submit
The names assigned to the name attributes, e.g.
firstname, lastname, allow user input data to be
associated with these names.
E.g. If the browser user enters the following data into the
two text boxes:
name/value pairs
John
Ivan firstname="Ivan"
Smith
Ivanov lastname="Ivanov"
E.g. firstname="Ivan"&lastname="Ivanov"
Sent to the server
The default format for the transmission of form input data
from the browser to the server is a concatenation of
names and values, separated by &s
name1="value1"&name2="value2"&name3="value3" ...
E.g.
firstname="Ivan"&lastname="Ivanov"
Using GET method to invoke server-side script
GET script?name1="value1"&name2="value2"
Script
Name-Value pairs
https://www.google.bg/search?q=aubg&ie=utf-8&oe=utf-
8&client=firefox-b&gfe_rd=cr&ei=bNSSWfnBLKjY8Aeb5aTYDw
Note: for the HTTP GET method, all that is sent to the
server is the initial line plus one or more header lines.
Followed by a blank line.
The HTML in the Web form to achieve this use of the HTTP
POST method would look something like this
Both PHP and ASP.NET provide means for accessing the data sent
with GET and POST
This means that a server-side script can access the data
sent by the browser and process it.
GET or POST Which one to use?
POST method embeds the name/value pairs inside the body of the
HTTP request message and the information is sent to the server.
3. What is the attribute of the HTML form element that defines the
server-side script that will process the form?
7. How is user input sent to a server script if the GET method has
been specified?
Discussion
http://www.w3schools.com/tags/ref_httpmethods.asp
https://www.cs.tut.fi/~jkorpela/forms/methods.html
http://blog.teamtreehouse.com/the-definitive-guide-to-get-vs-post
http://javarevisited.blogspot.com/2012/03/get-post-method-in-http-and-https.html
Questions?