01 - Web Programming Introduction

1.1 Introduction of Web Server and Web Browser

Web Server is a program used for delivering Web Pages to the respective client. The Web Server uses client server architecture for execution of the web services. HTTP protocol is used for communication between the server and the client in the system.

Each Web Server must have the following two properties:

  • An IP address of the Web Server
  • Domain name of the Web Server used for communication

1.1.1 Web Server Architecture

The pictorial representation of the Web Server architecture is shown below. The main components of server in the Client Server architecture are as mentioned below:

  • Data Server
  • Database Management Server (DBMS)
  • Web Server
  • Web Browser

Fig. (a)

The Request is sent from the client to the Web Server through Request object. The Web Server performs the processing and send the data to the application server. The data is received by the Database server for some database operations. The Database Management Structure performs the query operations and the responds output is send back to the Database Server. The Database Server send the data back to the client through Response object through Web Server.

1.1.2 Web Browser

Web Browser is an application used to retrieve, present, and transfer information on World Wide Web. Each Web Browser has a Uniform Resource Identifier (URI). The information regarding a particular browser can be located through the URL of the respective browser.

Internet Explorer, Google Chrome, Opera, Mozilla Firefox, Safari are different Web Browsers that are used to access the information.

1.2 HTTP Protocol

Hyper Text Transfer Protocol is an application protocol that defines the format of messages and actions Web Server must perform. HTTP is a stateless protocol. Each command in the HTTP protocol is executed without depending on the previous commands executed on the Web Server.

The HTTP protocol uses the request response structure in the client server architecture. The protocol is located in the application layer of the Internet Protocol suite.

The execution of the HTTP protocol in the client server architecture is mentioned below:

Fig. (b)

The client/user send the request to the server through the request object. Server performs the necessary operations and responds the result back to the client. HTTP protocol is used as communication protocol between the client and the server.

1.3 Comparison between HTTP GET and POST methods

User can interact with websites through GET and POST methods. Both the methods have respective functionalities to be performed. GET method is useful for retrieving information from the URI. The method can be re-issued again without effecting other operations in the system. It is safe to use over the web browser. GET method can supply data in the form of cookies and query string.

POST method is used for operations like storing, updating and ordering of data. The POST method is not safe for repetitive use as it can threaten the user security over web. POST method can be used when large amount of data needs to be sent to the server. There is no upper limit on the data that can be sent to the server. The POST request message has a content body used to send parameters.

Properties

GET

POST

Parameter History

The parameters are present in the URL of the browser. Hence are saved in the browser history

The parameters are not saved in the browser history

Data Caching

Data can be cached by the user

Data cannot be cached by the user

Data Type

ASCII characters are allowed

No restrictions on the data type

Bookmark

Data can be bookmarked

Data cannot be bookmarked

Data length

The data is added to the URL, resulting in the limitations to the URL length

The URL length is not restricted for the user

Back/Reload data

Data will not be re-submitted to the server after the respective action is performed

Data will be re-submitted to the server after the respective action is performed

Data Visibility

The data is present in the URL and hence is visible to the user

The data is not present in the URL and hence is not visible to the user

Security

Data is sent through URL and can be easily hacked. Less secure for sending sensitive information

Data is not stored in the browser history or logs and hence is more secure for the use

Data Limitation

Data length is restricted since the data is embedded in the URL

Data length is not restricted as the data is not embedded in the URL. User can send image files, data sheets.

 

 

1.4 HTTP Request and Response Structure

1.4.1 HTTP Request

HTTP Request is used when the user wants to retrieve the information from a web server. When a user visits a web page the HTTP Request to the web server through the HTTP protocol. The web server receives the request, and it responds as a web page. For every page request the process is repeated.

The HTTP Request consists of the following components.

  • HTTP Request Method
  • HTTP Request Headers
  • HTTP Request Body

1) HTTP Request Method - The HTTP Request method syntax is

GET http://URL path/protocol version

For example, the HTTP request for the Google website will be

GET http://www.google.com/HTTP/1.1

2) HTTP Request Headers - The headers are used to communicate about the client. Some of the headers used by the user are Content-Type, User-Agent, Accept-Encoding, Content-Length.

3) HTTP Request Body - The Request body contains the information to be sent to the HTTP server. The HTTP header and the body are separated through a line. The blank line is a compulsory part to be included in the body of the code.

1.4.2 HTTP Response

The user requests for a web page through the request object. HTTP response object is used to respond back to the HTTP request submitted by the user. HTTP response object do not need a constructor. The success of the HTTP response method can be determined by the code provided after processing the request.

The HTTP Response must contain the following fields:

  • Version of Protocol
  • Status Code
  • Date and Time
  • Response Headers
  • Response body

1) Version Of Protocol - It is used to determine the version of the HTTP protocol used in the code.

2) Status Code - The Status Code determines the success of the response. The value ‘200’ states the Status Code response. The value ‘404’ states that the requested file was not found at HTTP server machine.

3) Date and Time - It specifies the Date and Time of the response generated by the server.

4) Response Headers - The Response Headers contain information about the server machine. The headers are formed on the server machine. Some of the Response Headers are Content-Type, Content-Length, and Last Modified.

5) Response Body - It contains the response to be delivered to the client. The HTML code is the body of the content in the response.

Like us on Facebook