Jntuk CN Unit Vi
Jntuk CN Unit Vi
Jntuk CN Unit Vi
Fig. - URL
The protocol is the client/server program used to retrieve the document. Eg: FTP, HTTP.
The host is the computer on which the information is located, the name of the computer can be an
alias.
Host can be any name given to the computer that hosts the Web page. (optionally begins with www)
The URL can optionally contain the port number of the server. If the port is included, it is inserted
between the host and the path, and it is separated from the host by a colon.
Path is the pathname of the file where the information is located. Note that the path can itself contain
slashes to separate the directories from the subdirectories and files.
6.1.4. Cookies- Creation and Storage of Cookies
Steps involved in creation and storage of Cookies
When a server receives a request from a client, it stores information about the client in a file or a
string. The information may include the domain name of the client, the contents of the cookie, a
timestamp, and other information depending on the implementation.
The server includes the cookie in the response that it sends to the client.
When the client receives the response, the browser stores the cookie in the cookie directory, which is
sorted by the domain server name.
Using Cookies
When a client sends a request to a server, the browser looks in the cookie directory to see if it can
find a cookie sent by that server.
If found, the cookie is included in the request. When the server receives the request, it knows that this
is an old client, not a new one.
Note that the contents of the cookie are never read by the browser or disclosed to the user. It is a
cookie made by the server and eaten by the server.
Cookies Usage Case Scenarios
Scenario 1 Site services available to only registered users.
The site that restricts access to registered clients only sends a cookie to the client when the client
registers for the first time. For any repeated access, only those clients that send the appropriate cookie are
allowed.
Scenario 2 :
An electronic store (e-commerce) can use a cookie for its client shoppers. When a client selects an item and
inserts it into a cart, a cookie that contains information about the item, such as its number and unit price, is
sent to the browser. If the client selects a second item, the cookie is updated with the new selection
information and so on. When the client finishes shopping and wants to check out, the last cookie is retrieved
and the total charge is calculated.
Scenario 3 :
A Web portal - When a user selects her favorite pages, a cookie is made and sent. If the site is accessed again,
the cookie is sent to the server to show what the client is looking for.
Scenario 4 :
Used by advertising agencies. An advertising agency can place banner ads on some main website that is often
visited by users. The advertising agency supplies only a URL that gives the banner address instead of the
banner itself. When a user visits the main website and clicks on the icon of an advertised corporation, a
request is sent to the advertising agency. The advertising agency sends the banner, a GIF file, for example,
but it also includes a cookie with the will of the user. Any future use of the banners ads to the database that
profiles the Web behavior of the user. The advertising agency has compiled the interests of the user and can
sell this information to other parties. This use of cookies has made them very controversial and some new
regulations needed to be devised to preserve the privacy of users.
6.2.1.2. HTML
HTML Hypertext Markup Language (HTML) is a language for creating Web pages. Data for a
Web page are formatted for interpretation by a browser.
Eg: <B> This is the text to be boldfaced.</B>
The two tags <B> and </B> are instructions for the browser. When the browser sees these two
marks, it knows that the text must be boldfaced.
HTML allows us to embed formatting instructions in the file itself. The instructions are included
with the text
A Web page is made up of two parts: the head and the body. The head is the first part of a Web
page. The head contains the title of the page and other parameters that the browser will use. The
actual contents of a page are in the body, which includes the text and the tags. Whereas the text is
the actual information contained in a page, the tags define the appearance of the document. Every
HTML tag is a name followed by an optional list of attributes, all enclosed between less-than and
greater-than symbols
< TagNarne Attribute = Value Attribute = Value ••• >
6.2.2. Dynamic documents
A dynamic document is created by a Web server whenever a browser requests the
document.
When a request arrives, the Web server runs an application program or a script that creates
the dynamic document.
The server returns the output of the program or script as a response to the browser that
requested the document.
A fresh document is created for each request, the contents of a dynamic document can vary
from one request to another.
A very simple example of a dynamic document is the retrieval of the time and date from a
server. Time and date are kinds of information that are dynamic in that they change from
moment to moment. The client can ask the server to run a program such as the date program
in UNIX and send the result of the program to the client.
Technologies used for Dynamic documents:
Common Gateway Interface (CGI)
Scripting Technologies for Dynamic Documents
Common Gateway Interface (CGI) - creates and handles dynamic documents. CGI is a set of
standards that defines how a dynamic document is written, how data are input to the program, and
how the output result is used.
CGI defines a set of rules that are common to any language or platform.
CGI can access other resources such as databases, graphical packages, and so on.
There is a set of predefined terms, variables, calls, and so on that can be used in any CGI
program.
Input When a program is executed, parameters can be passed to the program and provides
generic execution for different parameters.
Output The whole idea of CGI is to execute a CGI program at the server site and send the
output to the client (browser). The output is usually plain text or a text with HTML
structures; however, the output can be a variety of other things. It can be graphics
or binary data, a status code, instructions to the browser to cache the result, or instructions
to the server to send an existing document instead of the actual output and information about
output is in headers
CGI program always consists of two parts: a header and a body.
The header is separated by a blank line from the body.
Scripting Technologies for Dynamic Documents
The problem with CGI technology is the inefficiency that results if part of the dynamic
document that is to be created is fixed and not changing from request to request.
A few technologies like JSP, PHP, ASP, etc. have been involved in creating dynamic
documents using scripts.
Dynamic documents are sometimes referred to as server-site dynamic documents.
Java Applets
Java allows a programmer to write an active document (an applet) and a browser to run it.
An applet is a program written in Java on the server.
It can also be a stand-alone program that doesn't use a browser.
It is compiled and ready to be run.
The document is in byte-code (binary) format.
The client process (browser) creates an instance of this applet and runs it.
A Java applet can be run by the browser in two ways.
In the first method, the browser can directly request the Java applet program in the URL and
receive the applet in binary form.
In the second method, the browser can retrieve and run an HTML file that has embedded the
address of the applet as a tag.
JavaScript
The idea of scripts in dynamic documents can also be used for active documents.
If the active part of the document is small, it can be written in a scripting language; then it
can be interpreted and run by the client at the same time.
The script is in source code (text) and not in binary form.
The scripting technology used in this case is usually JavaScript.
JavaScript, which bears a small resemblance to Java, is a very high level scripting language
developed for this purpose.
Active documents are sometimes referred to as client-site dynamic documents.
6.3. HTTP
The Hypertext Transfer Protocol (HTTP) is a protocol used mainly to access data on the World Wide Web.
HTTP functions as a combination of FTP and SMTP.
Main concepts
HTTP Transaction
Persistent Versus Non-Persistent Connection
Proxy Server
General header gives general information about the message and can be present in both a request and a
response.
Request header can be present only in a request message and it specifies the client's configuration and the
client's preferred document format.
Fig. Request headers
Response header can be present only in a response message. It specifies the server's configuration and
special information about the request.
Entity header gives information about the body of the document may appear in both response and request
messages.
6.3.1.4. Body
Body can be present in a request or response message. Usually, it contains the document to be sent or
received.
This example retrieves a document. We use the GET method to retrieve an image with the path
/usr/bin/image1. The request line shows the method (GET), the URL, and the HTTP version (1.1). The header
has two lines that show that the client can accept images in the GIF or JPEG format. The request does not
have a body. The response message contains the status line and four lines of header. The header lines define
the date, server, MIME version, and length of the document. The body of the document follows the header
(see Figure 27.16).
WWW Model