Unit I: Web Essentials: Clients, Servers, and Communication - Web Technologies II - BCA Notes (Pokhara University)

Breaking

Friday, August 2, 2019

Unit I: Web Essentials: Clients, Servers, and Communication - Web Technologies II

Review of Web Technologies I:

Web Essentials: Clients, Servers, and Communication, Review of Web Technologies I, Basic internet protocols, HTTP request message, HTTP response message, Web clients, Web servers, Different architectures of connection, Client side Vs server side scripting language,

Introduction:

To make websites look and function a certain way, web developers utilize different languages. The three core languages that make up the World Wide Web are HTML5, CSS, and JavaScript.

In the IT world, the internet is an essential platform, whether it’s for developing or for consumer use. When developing a website, typically three main languages come into play. These languages are JavaScript, CSS, and HTML. HTML is the backbone of most webpages. Essentially, it is used to create the structure of how a specific website would look like, from the headings to the paragraphs, the body, links, and even images.

Markup Languages:

Markup languages are the languages in which the web is written. The most common markup language used is HTML, which uses tags to annotate text so that a computer can then manipulate the text. Most markup languages are human-readable and use annotations that are distinguishable from the annotated text. There are many different kinds of markups and languages, but all are consistent in the way in which they annotate documents.

Hypertext:

Hypertext is defined as the arrangement of information inside a database that allows the user to receive information and to navigate from one document to another by clicking on highlighted words or pictures inside the primary document. Hypertext is the base of the World Wide Web, because it enables the user to click on other links to get more information. Hypertext is a term used for all links, whether it appears as texts or other graphical part.

Hypertext Markup Language (HTML):

HTML is the conventional markup language used to create and edit web pages and web applications. HTML is used for creating the basic structure of a website. HTML consists of different elements preceded by an opening tag, <tag>, and a closing tag, </tag>. The content between the tags, <html> and </html>, is the content of the webpage. The content between the tags, <head> and </head>, is the title of the webpage. This text is displayed between the <title> and </title> tags. The content between the tags, <body> and </body>, is the main content of the webpage. The content can include links, paragraphs, headings, and various other elements.

Here Are The Most Commonly Used HTML Tags:

Tag
Description
<h1> - <h6>
Gives a web page a heading. 1 is the largest heading we can have and 6 is the smallest.
<p>
Starts a paragraph on our web page.
<i>
Italic font style.
<b>
Bold font style.
<a>
Inserts hyperlinks onto a web page.
<ul> & <li>
Starts an unordered or ordered list.
<!DOCTYPE>
Defines the document type of the web page.
<!-- -->
Allows us to insert comments into our HTML code. Comments aren't displayed in on the web page but are helpful for organization.
<img>
Inserts an image onto a web page.
<br>
Inserts a line break between bodies of text.

HTML Major Versions:

HTML 2.0:

Published in 1995, HTML 2.0 flushed out the RFC system, allowing detailed mechanical explanations of the system.

HTML 3.2:

Published in 1997, HTML 3.2 performed major housecleaning on the structure of HTML. It removed mathematical formulas, reconciled code overlap, and adopted Netscape's Visual Markup Tags.

HTML 4.0:

Published at the end of 1997, HTML 4.0 introduced 3 different versions and browser-specific plugins. 4.0 Allowed custom experiences tailored to specific browsers.

XHTML:

Released in 2000, XHTML fused HTML and XML into a language that was very precise, almost too precise. XHTML is widely considered a tedious and difficult language.

HTML 5.0:

Released in 2014, HTML 5.0 is the currently used version of HTML. HTML 5.0 removed some of the tedium and severity of XHTML while keeping its ability to remain precise and detailed.

Hypertext Transfer Protocol (HTTP):

HTTP is the protocol used by the World Wide Web that determines how messages are formatted and transmitted. It also directs web servers and browsers to what actions they should take in reaction to several commands. When you open your web browser and enter a URL, you are using HTTP. The Web server directs it to get and transmit the requested Web page based on the HTTP command that is sent.

HTTP Protocol:

HTTP is an application used as the fundamental foundation of communication on the web. HTTP is the first letter you type in when inputting a web address. HTTP is a request-response protocol. The client might request something and the HTTP allows the client to access the information. Like when we updated our virtual machines the request we wanted was to go get updates for the software and HTTP request went out and got updates. If you were on a bank website or the wiki book site it would be https the‘s’ meaning secure. That means that the computer is communicating on a secure network.

Cascading Style Sheets (CSS):

CSS is a style sheet language standard set by W3C (World Wide Web Consortium) used to create and edit the visual presentation of web pages. CSS allows web developers to isolate a web page's content and visual styles into separate documents and gives better page layout control. An external CSS sheet is generally linked to HTML and XHTML, it also can be linked to XML, SVG, and XUL. HTML and JavaScript, with CSS, is a vital part of the technology used by the majority of interfaces for websites. This is also used in interfaces for mobile devices making the websites more engaging.

Here Are The Most Commonly Used CSS Tags:

Tag
Description
background
A shorthand property for setting all the background properties in one declaration.
colour
Sets the colour of the text.
opacity
Sets the opacity level for an element.
border
Sets all the border properties in one declaration.
border-color
Sets the colour of the four borders.
float
Specifies whether or not a box should float
padding
Sets all the padding properties in one declaration.
/*...*/
Allows you to insert comments into your CSS code. Comments aren't displayed in on the web page but are helpful for organization.
width
Sets the width of an element.
clear
Specifies which sides of an element where other floating elements are not allowed.

Types of CSS:

CSS can be incorporated with HTML in 3 different ways; Inline, Internal, and External.

Inline Styles:
Inline styles add style to a single element on the page by placing 'style' after the element we wish to be styled.
Ex: h2 style = "color: blue"

Internal Styles:
Internal styles create a style for a single document because the CSS is stored in the head of the HTML document. Internal styles are placed using a <style> tag around all style selectors.
Ex: <style>
body {background-color: white;}
/*This is a comment!
'Body' is the selector,
'background-color' is the declaration*/
h2 {color: blue;}
</style>

External Styles:
External style sheets exist in separate documents from HTML documents, allowing for better organization of style and structure. An external style sheet can be linked to all HTML documents making up a web site, allowing a web developer to style the entire site (all pages) using one document.

Web Design Programs:

Web Design Programs help the webpage creator manage and create the content of a website. Many Web Design programs have many built-in tools that ease the process of creating a website. Such programs are Dreamweaver and Sublime. There are also publishing programs like WordPress and Ghost that allow the user to have more of a GUI based interface for blogging and managing a website.

Sublime:

Sublime is a text editor that allows web developers, programmers, software engineers, etc. manipulate code. It's not only for HTML and CSS it can be set-up for many different programming languages and new productivity tools. One contribution that Sublime has that many do not is the "Package Control" Tool. The tool gives you full access to an entire library of content to better your coding experience. For example, there is a package you can install called Emmet, helping in typing the massive amount of HTML, if you type "Html:5" and press "tab" then emmet will push out all the correct syntax for an HTML 5 document.

SASS:

SASS is somewhat like emmet but is more of a language. It is a Ruby engraved language that gives CSS much more capabilities like variables and nesting. Like emmet, it makes writing CSS much faster and more efficient saving the programmer lots of time.

Dynamic Web Content:

Client-Side Scripting:

Generally refers to computer programs on the web that are executed by the user's web browser, instead of on a web server, enabling web pages to be scripted. Client-side scripts do not require additional software on the server but instead utilize the user's web browser to understand the scripting language in which it is written.

Server-Side Scripting:

Server-side scripting is a technique used in web development that involves using scripts on a web server which produce a unique response for each user's request to the website.

Combination Technologies:

When both client-side and server-side scripting collectively builds a webpage it is known as a web application. This web application can manage user interaction, security, and help improve performance between the client and the server. Web applications can include anything from online stores to instant messaging services as long as both server and client sides execute scripts to achieve a common goal in unison.

JavaScript:

JavaScript is a scripting language that is used along with HTML and CSS as the three core components of the World Wide Web. JavaScript has first-class functions and is used on most websites. JavaScript does not have any I/O which means that it has to be embedded in the host environment. JavaScript is also used in PDF documents, game development, and desktop and mobile applications. JavaScript is most commonly used to make DHTML by adding client-side behaviour to HTML pages.

Worldwide Web Consortium:

Worldwide Web Consortium (W3C) is an international community of web members to meet the Web standards. It was founded by Tim Berners-Lee, an inventor of the Web, back in the 20th century. W3C is designed to reach the full potential of the Web and to make it accessible to all users from all over the world. Also, another aim for W3C was to make standards to maintain the growth of the Web in a single direction rather than splitting into competing groups. Here are some of the standards for W3C:
a.  Accessibility
b. Web Authoring
c. Web Performance
d. Cascading Style Sheets
e. HTML5
f. Web Fonts
g. Widgets
h. Media Access
i. Mobile Web Applications
j. Internationalization of Web Design and Applications
k. Mobile Web Authoring
l.  XML
m. Graphics
n. RDF
o. HTTP
p. And many more

Basic Internet Protocols:

Network protocols are the set of rules that governs data communication. Types of protocols are explained below:
Web Essentials: Clients, Servers, and Communication, Review of Web Technologies I, Basic internet protocols, HTTP request message, HTTP response message, Web clients, Web servers, Different architectures of connection, Client side Vs server side scripting language,

1. TCP (Transmission Control Protocol):

When information is sent over the Internet, it is generally broken up into smaller pieces or "packets". The use of packets facilitates speedy transmission since different parts of a message can be sent by different routes and then reassembled at the destination. It is also a safety measure to minimize the chances of losing information in the transmission process. TCP is the means for creating the packets, putting them back together in the correct order at the end, and checking to make sure that no packets got lost in transmission. If necessary, TCP will request that a packet be resent.

2. IP (Internet Protocol):

Internet Protocol (IP) is the method used to route information to the proper address. Every computer on the Internet has to have its own unique address known as the IP address. Every packet sent will contain an IP address showing where it is supposed to go. A packet may go through several computer routers before arriving at its final destination and IP controls the process of getting everything to the designated computer. Note that IP does not make physical connections between computers but relies on TCP for this function. IP is also used in conjunction with other protocols that create connections.

3. HTTP (HyperText Transfer Protocol):

HTTP is a communication protocol. It defines a mechanism for communication between the browser and the webserver. It is also called request and response protocol because the communication between browser and server takes place in request and response pairs. It uses port 80.

4. HTTPS(Hypertext Transfer Protocol over Secure Socket Layer):

HTTPS was first introduced by Netscape. HTTPS takes care of secure communication between a web server and a web browser. HTTPS typically handles credit card transaction and other sensitive data. A Web page using this protocol will have https: at the front of its URL. It uses port 443.

5. FTP (File Transfer Protocol):

File Transport Protocol is a program that allows users and computers to send and receive large portions of data through a private or public network. It can also be used to send configuration files and software updates to network devices, such as switches and routers. FTP uses ports for communications and also uses encryption to protect the information being received and sent. It uses port 20 for data transfer and port 21 for connection.

6. SMTP (Simple Mail Transfer Protocol):

SMTP is a TCP/IP protocol used in sending and receiving e-mail. However, since it is limited in its ability to queue messages at the receiving end, it is usually used with one of two other protocols POP3 or IMAP that let the user save the messages in a server mailbox and download them periodically from the server. In other words, users typically use a program that uses SMTP for sending e-mail and either POP3 or IMAP for receiving e-mail. On UNIX based systems, send mail is the most widely-used SMTP server for e-mail. It uses port 25.

7. POP (Post Office Protocol):

POP is one of the most commonly used protocols used to receive e-mail on many e-mail clients. There are two different versions of POP: POP2 and POP3. POP2 was an early standard of POP that was only capable of receiving e-mail and required SMTP to send an e-mail. POP3 is the latest standard and can send and receive e-mail only using POP, but can also be used to receive e-mail and then use SMTP to send an e-mail.

POP3 is designed to delete mail on the server as soon as the user has downloaded it. However, some implementations allow users or an administrator to specify that mail is saved for some time. POP can be thought of as a "store-and-forward" service. It uses port 110.

8. IMAP (Internet Mail Access Protocol):

IMAP (Internet Message Access Protocol) is a standard email protocol that stores email messages on a mail server but allows the end-user to view and manipulate the messages as though they were stored locally on the end user's computing device(s). This allows users to organize messages into folders, have multiple client applications know which messages have been read, flag messages for urgency or follow-up and save draft messages on the server.

IMAP can be contrasted with another client/server email protocol, Post Office Protocol 3 (POP3). With POP3, the mail is saved for the end-user in a single mailbox on the server and moved to the end user's device when the mail client opens. While POP3 can be thought of as a "store-and-forward" service, IMAP can be thought of as a remote file server. It uses port 143.

9. UDP (User Datagram Protocol):

The User Datagram Protocol is one of the core members of the internet protocol suite. UDP uses a simple connectionless transmission model with a minimum of protocol mechanism. UDP provides checksums for data integrity, and port numbers for addressing different functions at the source and destination of the datagram. It has no handshaking dialogues, and thus exposes the user’s program to any unreliability of the underlying network and so there is no guarantee of delivery, ordering, or duplicate protection. If error correction facilities are needed at the network interface level, an application may use the TCP or SCTP (Stream Control Transmission Protocol) which are design for this purpose.

10. Telnet:

Telnet (short for TErminal NETwork) is a network protocol used to provide a command-line interface for communicating with a device. Telnet is used most often for remote management but also sometimes for the initial setup for some devices, especially network hardware like switches, access points, etc. Managing files on a website are also something Telnet is sometimes used for. Telnet is sometimes written in uppercase as TELNET and may also be misspelt as Telenet. It uses port 23.

11. DHCP (Dynamic Host Configuration Protocol):

DHCP (Dynamic Host Configuration Protocol) is a protocol used to provide quick, automatic, and central management for the distribution of IP addresses within a network. DHCP is also used to configure the proper subnet mask, default gateway, and DNS server information on the device. It uses port 68.

HTTP - Overview:

The Hypertext Transfer Protocol (HTTP) is an application-level protocol for distributed, collaborative, hypermedia information systems. This is the foundation for data communication for the World Wide Web (i.e. internet) since 1990. HTTP is a generic and stateless protocol which can be used for other purposes as well using extensions of its request methods, error codes, and headers.
Web Essentials: Clients, Servers, and Communication, Review of Web Technologies I, Basic internet protocols, HTTP request message, HTTP response message, Web clients, Web servers, Different architectures of connection, Client side Vs server side scripting language,

Basically, HTTP is a TCP/IP based communication protocol, that is used to deliver data (HTML files, image files, query results, etc.) on the World Wide Web. The default port is TCP 80, but other ports can be used as well. It provides a standardized way for computers to communicate with each other. HTTP specification specifies how clients' request data will be constructed and sent to the server, and how the servers respond to these requests.

Basic Features:

Three basic features make HTTP a simple but powerful protocol:

1. HTTP Is Connectionless:

The HTTP client, i.e., a browser initiates an HTTP request and after a request is made, the client disconnects from the server and waits for a response. The server processes the request and re-establishes the connection with the client to send a response back.

2. HTTP Is Media Independent:

It means any type of data can be sent by HTTP as long as both the client and the server know how to handle the data content. It is required for the client as well as the server to specify the content type using appropriate MIME (Multipurpose Internet Mail Extensions) type.

3. HTTP Is Stateless:

As mentioned above, HTTP is connectionless and it is a direct result of HTTP being a stateless protocol. The server and client are aware of each other only during a current request. Afterwards, both of them forget about each other. Due to this nature of the protocol, neither the client nor the browser can retain information between different requests across the web pages.

Basic Architecture:

The following diagram shows a very basic architecture of a web application and depicts where HTTP sits:
Web Essentials: Clients, Servers, and Communication, Review of Web Technologies I, Basic internet protocols, HTTP request message, HTTP response message, Web clients, Web servers, Different architectures of connection, Client side Vs server side scripting language,

The HTTP protocol is a request/response protocol based on the client/server-based architecture where web browsers, robots and search engines, etc. act like HTTP clients, and the Web server acts as a server.

1. Client:

The HTTP client sends a request to the server in the form of a request method, URI, and protocol version, followed by a MIME (Multipurpose Internet Mail Extensions) like a message containing request modifiers, client information, and possible body content over a TCP/IP connection.

2. Server:

The HTTP server responds with a status line, including the message's protocol version and a success or error code, followed by a MIME (Multipurpose Internet Mail Extensions) like message containing server information, entity Meta information, and possible entity-body content.

HTTP - Messages:

HTTP is based on the client-server architecture model and a stateless request/response protocol that operates by exchanging messages across a reliable TCP/IP connection.

An HTTP "client" is a program (Web browser or any other client) that establishes a connection to a server for the purpose of sending one or more HTTP request messages. An HTTP "server" is a program (generally a web server like Apache Web Server or Internet Information Services IIS, etc.) that accepts connections to serve HTTP requests by sending HTTP response messages.

Web Essentials: Clients, Servers, and Communication, Review of Web Technologies I, Basic internet protocols, HTTP request message, HTTP response message, Web clients, Web servers, Different architectures of connection, Client side Vs server side scripting language,

HTTP makes use of the Uniform Resource Identifier (URI) to identify a given resource and to establish a connection. Once the connection is established, HTTP messages are passed in a format similar to that used by the Internet mail [RFC (Remote Function Call) 5322] and the Multipurpose Internet Mail Extensions (MIME) [RFC2045]. These messages include requests from the client to server and responses from server to client which will have the following format: HTTP-message = <Request> | <Response>; HTTP/1.1 messages

HTTP requests and HTTP responses use a generic message format of RFC 822 for transferring the required data. This generic message format consists of the following four items.
1. A Start-line
2. Zero or more header fields followed by CRLF (Carriage Return, Line Feed)
3. An empty line (i.e. a line with nothing preceding the CRLF) indicating the end of the header fields
4. Optionally a message body

Message Start-Line:

A start-line will have the following generic syntax: start-line = Request-Line | Status-Line
Example:
GET /hello.htm HTTP/1.1 (This is Request-Line sent by the client)
HTTP/1.1 200 OK (This is Status-Line sent by the server)

Header Fields:

HTTP header fields provide required information about the request or response, or about the object sent in the message body. There are four types of HTTP message headers:
a. General-header: These header fields have general applicability for both request and response messages.
b. Request-header: These header fields have applicability only for request messages.
c. Response-header: These header fields have applicability only for response messages.
d. Entity-header: These header fields define Meta information about the entity-body or, if nobody is present, about the resource identified by the request.

All the above-mentioned headers follow the same generic format and each of the header field consists of a name followed by a colon (:) and the field value as follows:
message-header = field-name ":" [ field-value ]

Following are the examples of various header fields:
User-Agent: curl/7.16.3 libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3
Host: www.example.com
Accept-Language: en, mi
Date: Mon, 27 Jul 2009 12:28:53 GMT
Server: Apache
Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT
ETag: "34aa387-d-1568eb00"
Accept-Ranges: bytes
Content-Length: 51
Vary: Accept-Encoding
Content-Type: text/plain

Message Body:

The message body part is optional for an HTTP message but if it is available, then it is used to carry the entity-body associated with the request or response. If the entity-body is associated, then usually Content-Type and Content-Length headers lines specify the nature of the body associated.

A message body is the one which carries the actual HTTP request data (including form data and uploaded, etc.) and HTTP response data from the server (including files, images, etc.). Shown below is the simple content of a message body:
<html>
   <body>
      <h1>Hello, World!</h1>
   </body>
</html>

HTTP Requests Message:

An HTTP client sends an HTTP request to a server in the form of a request message which includes the following format:
1.  A Request-line
2. Zero or more header (General|Request|Entity) fields followed by CRLF
3. An empty line (i.e. a line with nothing preceding the CRLF) indicating the end of the header fields
4. Optionally a message-body
Web Essentials: Clients, Servers, and Communication, Review of Web Technologies I, Basic internet protocols, HTTP request message, HTTP response message, Web clients, Web servers, Different architectures of connection, Client side Vs server side scripting language,

1. Request-Line:

The Request-Line begins with a method token, followed by the Request-URI and the protocol version, and ending with CRLF. The elements are separated by space SP characters.
Request-Line = Method SP Request-URI SP HTTP-Version CRLF

2. Request Method:

The request method indicates the method to be performed on the resource identified by the given Request-URI. The method is case-sensitive and should always be mentioned in uppercase. The following table lists all the supported methods in HTTP/1.1.
S.N.
Method and Description
1
GET
The GET method is used to retrieve information from the given server using a given URI. Requests using GET should only retrieve data and should have no other effect on the data.
2
HEAD
Same as GET, but it transfers the status line and the header section only.
3
POST
A POST request is used to send data to the server, for example, customer information, file upload, etc. using HTML forms.
4
PUT
Replaces all the current representations of the target resource with the uploaded content.
5
DELETE
Removes all the current representations of the target resource given by URI.
6
CONNECT
Establishes a tunnel to the server identified by a given URI.
7
OPTIONS
Describe the communication options for the target resource.
8
TRACE
Performs a message loop backtests along with the path to the target resource.

3. Request-URI:


The Request-URI is a Uniform Resource Identifier and identifies the resource upon which to apply the request. Following are the most commonly used forms to specify a URI:
Request-URI = "*" | absoluteURI | abs_path | authority

S.N.
Method and Description
1
The asterisk * is used when an HTTP request does not apply to a particular resource, but to the server itself, and is only allowed when the method used does not necessarily apply to a resource. For example:
OPTIONS * HTTP/1.1
2
The absoluteURI is used when an HTTP request is being made to a proxy. The proxy is requested to forward the request or service from a valid cache, and return the response. For example:
GET http://bcanotespu.blogspot.com/pub/WWW/TheProject.html HTTP/1.1
3
The most common form of Request-URI is used to identify a resource on an origin server or gateway. For example, a client wishing to retrieve a resource directly from the origin server would create a TCP connection to port 80 of the host " bcanotespu.blogspot.com " and send the following lines:
GET /pub/WWW/TheProject.html HTTP/1.1
Host: bcanotespu.blogspot.com
Note that the absolute path cannot be empty; if none is present in the original URI, it MUST be given as "/" (the server root).

4. Request Header Fields:

The request-header fields allow the client to pass additional information about the request, and about the client itself, to the server. These fields act as request modifiers. Here is a list of some important Request-header fields that can be used based on the requirement:
a. Accept-Charset
b. Accept-Encoding
c. Accept-Language
d. Authorization
e. Expect
f. From
g. Host
h. If-Match
i. If-Modified-Since
j. If-None-Match
k. If-Range
l. If-Unmodified-Since
m. Max-Forwards
n. Proxy-Authorization
o. Range
p. Referer
q. TE
r. User-Agent

Examples of Request Message:

Now let's put it all together to form an HTTP request to fetch hello.htm page from the web server running on tutorialspoint.com
GET /hello.htm HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host:bcanotespu.blogspot.com
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

Here we are not sending any request data to the server because we are fetching a plain HTML page from the server. Connection is a general-header and the rest of the headers are request headers. The following example shows how to send form data to the server using the request message body:
POST /cgi-bin/process.cgi HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: bcanotespu.blogspot.com
Content-Type: application/x-www-form-urlencoded
Content-Length: length
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
licenseID=string&content=string&/paramsXML=string

Here the given URL /cgi-bin/process.cgi will be used to process the passed data and accordingly, a response will be returned. Here content-type tells the server that the passed data is a simple web form data and length will be the actual length of the data put in the message body. The following example shows how we can pass plain XML to our web server:
POST /cgi-bin/process.cgi HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: bcanotespu.blogspot.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://clearforest.com/">string</string>


HTTP Responses Message:

After receiving and interpreting a request message, a server responds with an HTTP response message:
1.  A Status-line
2. Zero or more header (General|Response|Entity) fields followed by CRLF
3. An empty line (i.e., a line with nothing preceding the CRLF) indicating the end of the header fields.
4. Optionally a message-body
Web Essentials: Clients, Servers, and Communication, Review of Web Technologies I, Basic internet protocols, HTTP request message, HTTP response message, Web clients, Web servers, Different architectures of connection, Client side Vs server side scripting language,

1. Message Status-Line:

Status-Line consists of the protocol version followed by a numeric status code and its associated textual phrase. The elements are separated by space SP characters.
Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF

2. HTTP Version:

A server supporting HTTP version 1.1 will return the following version information:
HTTP-Version = HTTP/1.1

3. Status Code:

The Status-Code element is a 3-digit integer where first digit of the Status-Code defines the class of response and the last two digits do not have any categorization role. There are 5 values for the first digit:
S.N.
Code and Description
1
1xx: Informational
It means the request was received and the process is continuing.
2
2xx: Success
It means the action was successfully received, understood, and accepted.
3
3xx: Redirection
It means further action must be taken to complete the request.
4
4xx: Client Error
It means the request contains incorrect syntax or cannot be fulfilled.
5
5xx: Server Error
It means the server failed to fulfil an apparently valid request.

HTTP status codes are extensible and HTTP applications are not required to understand the meaning of all registered status codes.

4. Response Header Fields:

The response-header fields allow the server to pass additional information about the response which cannot be placed in the Status- Line. These header fields give information about the server and about further access to the resource identified by the Request-URI.
a. Accept-Ranges
b. Age
c. ETag
d. Location
e. Proxy-Authenticate
f. Retry-After
g. Server
h. Vary
i. WWW-Authenticate

Examples of Response Message:

Now let's put it all together to form an HTTP response for a request to fetch the hello.htm page from the webserver running on tutorialspoint.com
HTTP/1.1 200 OK
Date: Mon, 27 Jul 2009 12:28:53 GMT
Server: Apache/2.2.14 (Win32)
Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT
Content-Length: 88
Content-Type: text/html
Connection: Closed

<html>
<body>
<h1>Hello, World!</h1>
</body>
</html>

The following example shows an HTTP response message displaying error condition when the web server could not find the requested page:
HTTP/1.1 404 Not Found
Date: Sun, 18 Oct 2012 10:36:20 GMT
Server: Apache/2.2.14 (Win32)
Content-Length: 230
Connection: Closed
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
<title>404 Not Found</title>
</head>
<body>
   <h1>Not Found</h1>
   <p>The requested URL /t.html was not found on this server.</p>
</body>
</html>

Following is an example of an HTTP response message showing error condition when the webserver encountered a wrong HTTP version in the given HTTP request:
HTTP/1.1 400 Bad Request
Date: Sun, 18 Oct 2012 10:36:20 GMT
Server: Apache/2.2.14 (Win32)
Content-Length: 230
Content-Type: text/html; charset=iso-8859-1
Connection: Closed

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
   <title>400 Bad Request</title>
</head>
<body>
   <h1>Bad Request</h1>
   <p>Your browser sent a request that this server could not understand.</p>
   <p>The request line contained invalid characters following the protocol string.</p>
</body>
</html>


Different Architectures of Connection:

Client-Server Architecture:

The Client-Server network model is a widely used, network model. Here, Server is a powerful system that stores the data or information in it. On the other hands, the Client is the machine which let the users access the data on the remote server.
Web Essentials: Clients, Servers, and Communication, Review of Web Technologies I, Basic internet protocols, HTTP request message, HTTP response message, Web clients, Web servers, Different architectures of connection, Client side Vs server side scripting language,

The system administrator manages the data on the server. The client machines and the server are connected through a network. It allows the clients to access data even if the client machine and server are far apart from each other.

In Client-Server model, the client process on the client machine sends the request to the server process on the server machine. When the server receives the client request, it lookouts for the requested data and sends it back with the reply.

As all the services are provided by a centralized server, there may be chances of server getting bottlenecked, slowing down the efficiency of the system.

Peer-to-Peer Architecture:

Unlike Client-Server, the Peer-to-Peer model does not distinguish between client and server instead each node can either be a client or a server depending on whether the node is requesting or providing the services. Each node is considered as a peer.
Web Essentials: Clients, Servers, and Communication, Review of Web Technologies I, Basic internet protocols, HTTP request message, HTTP response message, Web clients, Web servers, Different architectures of connection, Client side Vs server side scripting language,

To become a part of peer-to-peer, a node must initially join the network. After joining it must start to provide services to and must request the services from other nodes in the peer-to-peer system. There are two ways to know which node provides which services; they are as follow:

a. When a node enters the peer-to-peer system, it must register the services it will be provided, into a centralized lookup service on the network. When a node desires for any specific service it must contact centralized lookup services to check out which node will provide the desired services. Rest of the communication is done by the desiring node and the service providing node.

b.m A node desiring for the specific services must broadcast the request for services to all other nodes in the peer-to-peer system. The node providing the requested service will respond to the node making the request.

Peer-to-Peer network has the advantage over client-server that the server is not bottlenecked as the services are provided by the several nodes distributed in a peer-to-peer system.

Difference between Client-Server and Peer To Peer Architecture:

Basis
Client-Server
Peer-To-Peer:
Basic
There is a specific server and specific clients connected to the server.
Clients and server are not distinguished; each node act as client and server.
Service
The client request for service and server respond with the service.
Each node can request for services and can also provide the services.
Focus
Sharing the information.
Connectivity.
Data
The data is stored in a centralized server.
Each peer has its own data.
Server
When several clients request for the services simultaneously, a server can get bottlenecked.
As the services are provided by several servers distributed in the peer-to-peer system, a server in not bottlenecked.
Expense
The client-server are expensive to implement.
Peer-to-peer is less expensive to implement.
Stability
Client-Server is more stable and scalable.
Peer to Peer suffers if the number of peers increases in the system.

Differentiate between Client Side and Server Side Scripting Language:

Client Side Scripting Language
Server Side Scripting Language
Client-side scripting is used when the user’s browser already has all the code and the page is altered based on the user's input.
Server-side scripting is used to create dynamic pages based on several conditions when the user's browser makes a request to the server.
The Web Browser executes the client-side scripting that resides at the user’s computer.
The Web Server executes the server-side scripting that produces the page to be sent to the browser.
The browser receives the page sent by the server and executes the client-side scripts.
Server executes server-side scripts to send out a page but it does not execute client-side scripts.
Client-side scripting cannot be used to connect to the databases on the webserver.
 Server-side scripting is used to connect to the databases that reside on the webserver.
Client-side scripting can’t access the file system that resides at the webserver.
Server-side scripting can access the file system residing at the webserver.
The files and settings that are local at the user’s computer can be accessed using Client side scripting.
The settings that belong to the Web server can be accessed using Server-side scripting.
Client-side scripting is possible to be blocked by the user.
Server-side scripting can’t be blocked by the user.
Response from a client-side script is faster as compared to a server-side script because the scripts are processed on the local computer.
Response from a server-side script is slower as compared to a client-side script because the scripts are processed on the remote computer.
Examples of Client side scripting languages : JavaScript, VB script, etc.
Examples of Server-side scripting languages: PHP, JSP, ASP, ASP.Net, Ruby, Perl and many more.

No comments:

Post a Comment

If you have any doubt, then don't hesitate to drop comments.