Chapter 6 Server Side
Chapter 6 Server Side
Although the Internet and the World Wide Web are used interchangeably, they are not the same
thing. The Internet is the hardware part - it is a collection of computer networks connected
through either copper wires, fiber optic cables or wireless connections whereas, the World Wide
Web can be defined as the software part - it is a collection of web pages connected by hyperlinks
and referenced with Uniform Resource Identifiers(URI). In short, the World Wide Web is one of
the services provided by the Internet. Other services over the Internet include e-mail, chat, and
telephony and file transfer services.
The Web works on a client-server basis. Your computer is the client and the remote computers
that store electronic files are the servers.
When you enter something like http://www.google.com, the request goes to one of many special
computers on the Internet known as Domain Name Servers (DNS). All these requests are routed
through various routers and switches. The domain name servers keep tables of machine names
and their IP addresses, so when you type in http://www.google.com, it gets translated into a
number, which identifies the computers that serve the Google Web site to you.
When you want to view any page on the Web, you must initiate the activity by requesting a page
using your browser. The browser asks a domain name server to translate the domain name you
requested into an IP address. The browser then sends a request to that server for the page you
want, using a standard called Hypertext Transfer Protocol or HTTP.
The server should constantly be connected to the Internet ready to serve pages to visitors. When
it receives a request, it looks for the requested document and returns it to the Web browser.
When a request is made, the server usually logs the client's IP address, the document requested,
and the date and time it was requested.
A user enters a URL into a browser (for example, http://www.google.com). This request
is passed to a domain name server.
The domain name server returns an IP address for the server that hosts the Web site (for
example, 68.178.157.132).
The browser requests the page from the Web server using the IP address specified by the
domain name server.
The Web server returns the page to the IP address specified by the browser requesting the
page. The page may also contain links to other files on the same server, such as images,
which the browser will also request.
The browser collects all the information and displays to your computer in the form of
Web page.
Internet programming is the process of developing services (applications) that run on the
Internet. Internet programming includes broad variety of technologies spanning such diverse
areas such as protocols for communication networks, interfacing to databases, programming of
graphical user interfaces, or structuring information.
A web service is a kind of client/server process i.e.it needs interaction between client and server
computers. Therefore, Internet programming can be divided into two parts:
Client- side programming - to define the operations to be performed on the client’s machine
Server-side programming - to define the operations to be performed on the server
Skills required for Client –side programming Skills required for Server – side programming
HTML,XHTML PHP
CSS ASP
JavaScript JSP
XML etc. SQL and other database concepts etc.
Chapter -2
Web page development using HTML
2.1. What is HTML?
HTML stands for Hyper Text Mark-up Language. It is the language for building web pages and consists
of standardized codes or “tags” that are used to define the structure of information on the web page.
<tagname>content</tagname>
A Computer installed with a Browser (Example, Mozilla Firefox, Internet Explorer, Google chrome)
o The purpose of a browser is to read html documents and display them as web pages. The
browser doesn’t display the html tags but uses them to interpret the content of a page.
Text editor (Example: Notepad, WordPad, Gedit ,emacs)
o The purpose of a text editor is for writing the html code
DOCTYPE Declaration
<html>
<head>
Header related tags
</head>
<body>
Body related tags
</body>
</html>
An HTML document starts with DOCTYPE declaration that declares the version of HTML to which the
document conforms. The need for the DOCTYPE declaration is that web browsers need to know what
version of HTML/XHTML your web page is written in so that they will know how to display it.
The DOCTYPE declaration names the document type definition (DTD) in use for the document. A
Document Type Definition (DTD) is a set of Markup declarations that define an HTML document
structure with a list of legal elements and attributes. This DTD is associated with html document by
means of Document Type Declaration (DOCTYPE Declaration).
1. When performing HTML validation testing on a web page it tells the HTML validator which
version of HTML standard is used for writing the web page.
2. It tells the browser how to render the page in standards compliant mode.
Quirk Mode – renders the page as it would appear in old browsers. If there is no DOCTYPE
declaration, the browser will go into Quirk mode.
Standard Mode – will render the page as intended if the web page coding is valid.
1. You will not be able to use HTML validator to check the html document. HTML validation
requires DOCTYPE declaration.
2. The browser rendering the web page will process the coding in Quirks mode.
3. The style sheet may not be implemented as planned
There are many DOCTYPE declaration types which can be used in HTML depending on what version of
HTML is being used.
Since its initial introduction in late 1991, HTML has undergone many changes. But the first real standard
was HTMLL 2.0. Other HTML versions are HTML 3.0, HTML 3.2, HTML 4.0, HTML 4.01, XHTML
1.0, and HTML 5.
HTML 4.01 and XHTML 1.0 are commonly used for developing web applications. HTML 5 is the future
html version for developing web applications.
HTML 4.01 has three different document types: Strict, Transitional, Frameset. Therefore, each
document type needs a different DOCTYPE declaration.
i) Strict – The strict type is used with cascading style sheets and helps to ensure a clutter-free coding.
A clutter – free code is a code where the content is separated from the
presentation
HTML frames allow authors to present documents in multiple views, which may be
independent windows or sub windows.
2.5.2 html
Immediately after the DOCTYPE comes the <html> tag. It indicates that the contents of the page are in
HTTML.
The html element is the root element of the document tree and everything that follows is a descendant of
that element.
The html element breaks the html document into main sections – the head and body.
The head element contains metadata – information that describes the document itself, such as its title or
associates it with related resources, such as scripts and style sheets. The head element consists of the
following other elements.
The title tag –represents the document’s title or name. The content in the title is used to provide a heading
that appears in the browser’s title bar.
The link tag – tag defines a link between a document and an external resource, most often it is used to
link to external style sheets.
The meta tag – provides extra information about the web page; for example, which character encoding
the page uses, a summary of the page’s content etc.
The style tag - provides an area for internal page-specific) CSS styles.
All of these elements are optional and can appear in any order within the head
2.5.4 body
Defines the document’s body. Everything that you can see in the browser window (or viewport) is
contained inside this element, including paragraphs, lists, links, images, tables, and more.
HTML documents are made up of HTML elements. An HTML element is everything from the start tag to
the end tag. HTML elements are written with a start tag, with an end tag, and with the content in
between:
<tagname>content</tagname>
HTML elements follow a certain format regardless of how the element is used:
An HTML element starts with a start tag/opening tag
An HTML element ends with an end tag/closing tag
The element content is everything between the start tag and end tag
Some html elements don’t have content, hence are called empty elements (e.g. img, hr)
Empty elements are closed in the start tag (e.g. <br/>)
HTML elements can be nested in other html elements
Most HTML elements can have attributes i.e.
Examples of html elements:
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
<!DOCTYPE html>
<html lang="en-US">
<body>
<h1>My First Heading</h1>
HTML links are defined with the <a> tag. The link address is specified in the href attribute:
Size Attributes
HTML images are defined with <img> tag. The file name of the source (src), and the size of
the image (width and height) are all provided as attributes:
The image size is specified in pixels: width="104" means 104 screen pixels wide.
The alt Attribute
The alt attribute specifies an alternative text to be used, when an HTML element cannot be displayed.
The value of the attribute can be read by "screen readers". This way, someone "listening" to the webpage,
i.e. a blind person, can "hear" the element.
HTML use tags like <b>, <i> to modify the appearance of text, like bold or italic. These HTML tags are
called formatting tags.
The HTML <b> element defines bold text, without any extra importance.
Example:
The HTML <strong> element defines strong text, with added semantic "strong" importance.
Example:
Every HTML element has a default style (background color is white, text color is black, text-size is
12px…). Changing the default style of an HTML element, can be done with the style attribute.
This example changes the default background color from white to lightgrey:
Example:
<body style="background-color:lightgrey">
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
style="property:value"
Links are found in nearly all web pages. Links allow users to click their way from page to page. A link is
the “address” to a document (or a resource) located on the World Wide Web or elsewhere within your
own web server.
HTML links are also called hyperlinks. A hyperlink can be an element, a text, or an image that you can
click on, and jump to another document.
Example:
<!DOCTYPE html>
<html>
<body>
<p>
<a href=" http://www.w3schools.com/)">Visit w3schools</a>
</p>
</body>
</html>
This example will open the linked document in a new browser window or in a new tab:
_self Opens the linked document in the same frame as it was clicked (this is default)
_top Opens the linked document in the full body of the window
Example:
<a href="default.asp">
<img src="smiley.gif" alt="HTML tutorial" style="width:42px;height: 42px">
</a>
In HTML, images are defined with with the <img> tag. The img tag is empty which means that it contains
attributes only and it has no closing tag.
To display an image on a page, you need to use the src attribute. src stands for “source”. The value of the
src attribute is the URL of the image you want to display on your page.
http://www.w3schools.com/images/boat.gif
The alt attribute is used to define an alternate text for an image. The alt attribute tells the reader what he
or she is missing on a page if the browser can’t load images. The browser will then display the alternate
text instead of the image.
It is a good practice to include alternate text for every image on a page to improve the display and
usefulness of your document for people who have text-only browsers.
The alt attribute also helps to create accessible web pages for users with disabilities, especially those with
vision impairments who use text-based browsers.
Specialized software called a speech synthesizer can “speak” the alt attributes value so that a user with a
visual impairment knows what the browser is displaying.
Tables are an excellent way to organize and display information on a page. Tables are defined using the
<table> tag. A table is divided into rows with the <tr> tag, and each row is divided into data cells using
the <td> tag. The letters td stand for “table data,” which is the content of a data cell. A data cell can
contain text, images, lists, paragraphs, forms, horizontal rules, tables, and so on.
If you do not specify a border for the table, it will be displayed without borders.
A border can be added using the border attribute:
Example:
<table border="1" style="width:100%">
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
Cell padding specifies the space between the cell content and its borders. If you do not specify padding,
the table cells will be displayed without padding. To set the padding, use the CSS padding property:
Example:
<table border="1" style="padding:15xp" >
…
</table>
2.11.4 HTML Table Headings
Table headings are defined with the <th> tag. By default, all major browsers display table headings as
bold and centered:
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Points</th>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
Example:
<table style="width:100%">
<tr>
<th>Name</th>
<th colspan="2">Telephone</th>
</tr>
<tr>
<td>Bill Gates</td>
<td>555 77 854</td>
<td>555 77 855</td>
</tr>
</table>
Example:
<table style="width:100%">
<tr>
<th>First Name:</th>
<td>Bill Gates</td>
</tr>
<tr>
<th rowspan="2">Telephone:</th>
<td>555 77 854</td>
</tr>
<tr>
<td>555 77 855</td>
</tr>
</table>
Example:
<table style="width:100%">
<caption>Monthly savings</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$50</td>
</tr>
</table>
The <caption> tag must be inserted immediately after the <table> tag.
An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.
The list items will be marked with bullets (small black circles).
Example:
<!DOCTYPE html>
<html>
<body>
</body>
</html>
A style attribute can be added to an unordered list, to define the style of the marker:
Style Description
list-style-type:disc The list items will be marked with bullets (default)
list-style-type:circle The list items will be marked with circles
list-style-type:square The list items will be marked with squares
list-style-type:none The list items will not be marked
An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.
The list items will be marked with numbers.
Example:
<!DOCTYPE html>
<html>
<body>
<h2>Ordered List</h2>
<ol>
<li>Coffee</li>
<li>Tea</li>
</ol>
</body>
</html>
Type Description
type="I" The list items will be numbered with uppercase roman numbers
type="i" The list items will be numbered with lowercase roman numbers
2.12.3 HTML Description Lists
A description list, is a list of terms, with a description of each term.
Example:
<!DOCTYPE html>
<html>
<body>
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
</body>
</html>
<ul>
<li>Coffee</li>
<li>Tea
<ul>
<li>Black tea</li>
<li>Green tea</li>
</ul>
</li>
<li>Milk</li>
</ul>
</body>
</html>