Internet Programming and Web Design
Internet Programming and Web Design
MB A
Paper 4.4.2
ALA
AL AGAPPA
GAPPA UNIVERSITY
Karaikudi - 630 003 Tamil Nadu
Reviewer
Authors
All rights reserved. No part of this publication which is material protected by this copyright notice
may be reproduced or transmitted or utilized or stored in any form or by any means now known or
hereinafter invented, electronic, digital or mechanical, including photocopying, scanning, recording
or by any information storage or retrieval system, without prior written permission from the Publisher.
Information contained in this book has been published by VIKAS® Publishing House Pvt. Ltd. and has
been obtained by its Authors from sources believed to be reliable and are correct to the best of their
knowledge. However, the Publisher and its Authors shall in no event be liable for any errors, omissions
or damages arising out of use of this information and specifically disclaim any implied warranties or
merchantability or fitness for any particular use.
UNIT 1
Foundations for Internet Programming: An Overview of Internet Unit 1: Foundations for Internet
Programming, Web System Architecture, URL, Domain Name System, Programming (Pages 3-32)
Overview of HTTP, HTTP Request-Response, Generation of Dynamic
Web Pages Cookies, WWW Design Issues, Security and Encryption,
Developing Intranet Applications.
UNIT 2
Unit 2: Internet Programming
Internet Programming Languages: Java, Java in Windows, Common Languages
Gateway Interface (CGI), Perl: Strawberry Perl or Active Perl, (Pages 33-62)
Microsoft Internet Implementation.
Web technology revolutionizes the way information is exposed and circulated within NOTES
every organization and enables everyone to be in the distribution business. It includes
the development, hosting and maintenance of sites for big, medium and small companies.
Nowadays every organization is building a Website for the World Wide Web (WWW)
on the Internet. Most organizations are on a network be it LAN, WAN or MAN.
With Web technology and a network, every organization can build their own Websites
that are available to everyone on the authorized network. To build a Website one
requires a computer system, a network, browser software and server software. The
network must support the TCP/IP protocol and each computer must have an IP address
configured on it. The Internet provides free Web browser, Web server software, icons,
backgrounds, images and graphics to develop an attractive Website. A Web server
contains a bunch of files that are called by the server software when a user sends a
request through their Web browser. The Web browsers provide accessibility to various
available Websites to have the latest information online.
Programming languages enable you to create custom applications and add
functionality to it. On the Internet, programming languages enable you to create visual
animation, respond to user actions, validate forms and interact with databases to provide
solutions. Programming languages are of two types, namely interpreted and compiled.
The scripting languages are mostly interpreted, which means that you write the code
and the browser or server understands what to do with it. Compiled languages are
generally used for server side processing for Web applications. Programming
technologies generally use one or more programming language to create end-to-end
solutions for Web applications.
The Internet is a global network that uses the standard Internet Protocol Suite
(TCP/IP) to serve billions of users worldwide. A Web browser is a type of software
that retrieves and presents information resources on the Internet. In order for the
Internet to be a viable form of communication and information, standard are required
for the related technologies and languages. Three Internet standard organizations exist
to define technologies, specifications and languages, and to develop standards for
global communication networks, including the Internet and networking protocols. The
World Wide Web Consortium (W3C) provides standards, specifications and guidelines
for technologies that are commonly used on the Internet. The Internet, as its name
suggests, is an interconnection of networks at an international level. The World Wide
Web (WWW) is an architectural framework for accessing linked documents spread
out over thousands of machines all over the Internet. WWW made it possible for a site
to set up a number of pages of information containing text, pictures, sound and even
video with embedded links to other pages. It is a graphic variety of online hypertext
encyclopedia that lets you browse through the Internet’s vast resources simply by
clicking with your mouse.
Web technologies are referred as the interface between the Web servers and
their clients. There are several Web technologies, from simple to complex, which
include markup languages, programming interfaces and languages, and standards for
document identification and display.
Self-Instructional Material 1
Introduction This book, Internet Programming and Web Design, is aimed at giving the
students a fair thought of the foundations of the Internet programming and markup
languages, the basics of Web design and the basics of the Internet programming using
various languages to create a Web page with the help of graphics and animation. The
NOTES book comprises six units dealing with the foundations for the Internet programming,
WWW design issues, developing intranet application, the Internet programming
languages (Java, CGI, Perl), scripting languages (JavaScript, VBScript), SMTP, uses
of applets, introduction to HTML and SGML, creating an ActiveX control to activate
a page and the basics of Web design.
The book follows the self-instruction format wherein each unit begins with an
‘Introduction’ to the topic of the unit followed by an outline of the ‘Unit Objectives’.
The detailed content is then presented in a simple and structured form interspersed
with ‘Check Your Progress’ questions to facilitate a better understanding of the topics
discussed. The ‘Key Terms’ are given on respective pages to help the student revise
what he/she has learnt. A ‘Summary’ along with a set of ‘Questions and Exercises’ is
also provided at the end of each unit for effective recapitulation.
2 Self-Instructional Material
Foundations for Internet
UNIT 1 FOUNDATIONS FOR Programming
INTERNET PROGRAMMING
NOTES
Structure
1.0 Introduction
1.1 Unit Objectives
1.2 An Overview of Internet Programming
1.2.1 Major Features of the Internet
1.2.2 Working of the Internet
1.3 URL
1.4 Overview of HTTP
1.5 WWW
1.6 Developing Intranet Applications
1.7 Summary
1.8 Answers to Check your Progress
1.9 Question and Exercises
1.7 Summary
1.8 Answers to ‘Check Your Progress’
1.9 Questions and Exercises
1.0 INTRODUCTION
In this unit, you will learn about the basics of the Internet. The Internet is a 'network of
networks'. It can be visualized as a number of interconnected computers located at
physically disparate locations around the world. It is a global network of computers,
cutting across barriers and boundaries of countries, class or race. It comprises of
thousands of computer networks linked to each other. The Internet carries a vast
array of information resources and services, most notably the interlinked hypertext
documents of the World Wide Web (WWW) and the infrastructure to support
electronic mail. In this unit, you will also learn about the various features of the Internet
like Telnet, file transfer protocol, uniform resource locator, etc. Finally, you will learn
about intranet which is a standard term used for a set of private computer networks
operating within an organization. The intranet network technologies are used to ease
communication between people or work groups of an organization and also to enhance
the data sharing capacity of an organizational database.
4 Self-Instructional Material
• Online Shopping: Logically, the Internet has removed all barriers of distance Foundations for Internet
Programming
and nationality. You can shop for products and services across the world by
logging on to a Web portal. You can also pay your bills online using credit and
debit cards. You can also transfer money between different accounts with the
click of a mouse. NOTES
User’s
Computer
Modem Modem
Internet Backbone
For dial-up connections, regular telephone lines are used. Therefore, the quality
of connection is not always good.
Permanent Dedicated Connection
You can also have a dedicated Internet connection that typically connects you to ISP
through a dedicated phone line. A dedicated Internet connection is a permanent
telephone connection between two points. Computer networks that are physically
Dedicated Internet separated are often connected using leased or dedicated lines. These lines are preferred
connection: A permanent
telephone connection
because these are always open for communication traffic unlike the regular telephone
between two points lines that require a dialing sequence to be activated. Often this line is an ISDN (Integrated
Services Digital Network) line that allows transmission of data, voice, video and graphics
at very high speeds. ISDN applications have revolutionized the way business
communicates. ISDN lines support upward scalability which means that you can
transparently add more lines to get faster speeds – going up to 1.28 Mbps (Million
bits per second).
T1 and T3 are the other two types of commonly used dedicated line types for
the Internet connections T1 line is made up of fiber optic, which can carry nearly 60
times more data than any normal residential modem can carry. The T3 lines are made
up of 28 T1 lines, which normally operate at a signaling rate of 1.544 Mbit/s. Dedicated
lines are becoming popular because of their faster data transfer rates. Dedicated lines
are cost effective for the business that uses the Internet services extensively.
The Internet Protocols
The Internet protocols are required to transfer data over the networks and/or the
Internet in an efficient manner. When various computers are connected through a
computer network, it becomes necessary to use a protocol to efficiently use network
bandwidth and avoid collisions.
A network protocol defines a language that contains rules and conventions for
reliable communication between different devices over the network. For example, it
includes rules that specify how to package data into messages, how to acknowledge a
message and how to compress data.
6 Self-Instructional Material
A number of the Internet protocols are used nowadays. The most commonly Foundations for Internet
Programming
used protocols are as follows:
• Transmission Control Protocol/Internet Protocol (TCP/IP)
• HyperText Transfer Protocol (HTTP) NOTES
• File Transfer Protocol (FTP)
• Telnet
Transmission Control Protocol/Internet Protocol or TCP/IP
It is a protocol suite used to transfer data over the Internet. Two main protocols in this
protocol suite are as follows:
TCP: It forms the higher layer of TCP/IP and divides a message or a file into
smaller packets which are transmitted over the Internet. A TCP layer on the other side TCP: It forms the higher
receives these packets and reassembles the data packets into the original message. layer of TCP/IP and divides
a message or a file into
IP: It is the lower layer whose function is to handle the address part of each
smaller packets which are
packet to enable it to be delivered to the right destination. Usually, this address is transmitted over the Internet
checked by each gateway computer on the network so that it is identified where to
forward the message. This implies that all the packets of a message are delivered to
the destination regardless of the route used for delivering the packets.
The working of TCP/IP can be compared with shifting your residence to a new
location. This activity would involve packing your belongings in smaller boxes for easy
transportation with the new address and a number written on each of the boxes. You
would then load them on multiple vehicles. These vehicles may take different routes to
reach the same destination. The delivery time of vehicles depends on the amount of
traffic and the length of the route. Once the boxes are delivered to the destination, you
would check these to make sure that all have been delivered in good shape. After that,
you need to unpack the boxes and reassemble your house.
HyperText Transfer Protocol or HTTP
HTTP is a protocol for transferring files (text, image, sound, video and other
multimedia files) using the Internet. It is an application protocol that runs on top of
the TCP/IP protocol suite which is the foundation protocol of the Internet. It defines HTTP: It is a protocol for
how messages are formatted and transmitted and what actions Web servers and transferring files (text, image,
sound, video and other
Web browsers should take in response to the commands issued. HTTP is based on multimedia files) using the
a client-server architecture where your Web browser acts as a HTTP client making Internet.
requests to the Web server machines.
File Transfer Protocol or FTP
FTP is an application protocol used for exchanging files between computers over the
Internet. It is the simplest and most commonly used protocol for downloading/ uploading
a file from/to a server. For example, downloading a document or an article from a
Web site. Like other protocols, FTP also uses TCP/IP protocol suite for data transfer.
FTP also works on a client-server architecture where an FTP client program is
used to make a request to an FTP server (files can be stored on computers referred to
as FTP servers). Basic FTP support is usually provided as a part of the TCP/IP suite
of programs.
Self-Instructional Material 7
Foundations for Internet Telnet
Programming
Telnet is a protocol that allows you to access a remote computer provided you have
been given the permission to do so. It is typically referred to as ‘remote login’. Telnet
NOTES is based on a different concept from HTTP and FTP. HTTP and FTP allows you to
request specific files from remote computers only while with Telnet you log in as a
regular user on a remote machine with whatever privileges you may have been granted
on that computer to access specific application and data. A request for a connection to
a remote host which may be a computer lying physically in a neighbouring room or
miles away results in an invitation to log in with a user id and a password. If the request
is accepted, the user can enter commands through the Telnet program and these would
be executed as if they were being entered directly from the host machine. Once
connected, the user’s computer emulates the remote computer. Telnet is typically used
by program developers or anyone who needs to access data and/or applications located
at a particular host computer.
The Internet Addressing
Since the Internet consists of a large number of computers connected with each other,
it requires a proper addressing system to uniquely identify each computer in the network.
Each computer connected to the Internet is associated with a unique number and/or a
name called computer address. Before you wish to access any Web page on a computer,
you would require the computer address.
IP Address: An IP address is a unique number associated with each computer
making it uniquely identifiable amongst all the computers connected to the Internet.
This is a 32-bit number and is divided into four octets, such as 00001010 00000000
IP address: An IP address is
a unique number associated
00000000 00000110. For human readability, it is represented in a decimal notation,
with each computer making separating each octet with a period. The above number would therefore be represented
it uniquely identifiable as: 10.0.0.6.
amongst all the computers Each octet can range from 0 – 255, thus all IP addresses lie between 0.0.0.0 to
connected to the Internet
255.255.255.255 resulting in total 4294, 967,296 possible IP addresses. It may be
worth noting that no two machines (or hosts) can have the same IP address.
Domain Naming System or DNS: In a network, computers and devices can be
grouped as a unit with common rules and procedures. Such a group is called a domain.
Each domain name therefore corresponds to a group of IP addresses. Some examples
of domain names include Yahoo.com, Microsoft.com and abcuniv.edu. The last portion
of the domain name provides information on the kind of organization to which the
address belongs.
Commonly used abbreviations in domain names are summarized in Table 1.1.
Table 1.1 Abbreviations used in Domain Names
8 Self-Instructional Material
DNS is an Internet service that translates domain names to or from IP Foundations for Internet
Programming
addresses, which is the actual basis of addressing on the Internet. A DNS is
typically a database containing information about domain names and their
corresponding IP addresses (see Figure 1.2).
NOTES
www.tscpl.com 185.0.0.12
www.eg.com 195.102.230.2 195.102.230.2
…
DNS
185.0.0.12
www.tscpl.com
1.3 URL
The http is used as a protocol in which information resides on the domain called
aaa.bbb.edu. The information that resides in the host machine is taken as flower.html.
The host machine can either be protocol dependent or host dependent. A component
of URL is known as the path component. Sometimes the URL is also referred to as
‘Port’, that is, it is a port number by which TCP connection is possible to the remote
host machine. The default port for protocol is used if port is not specified. For instance,
Port 80 is known as default port for HTTP. The two ports, Port 20 and Port 21 are
used by ftp. The alternative port can be used in the following way:
http://aaa.bbb.edu:80/ flower.html
Table 1.3 shows some specific symbols and characters which are used by the URL.
These are, in fact, URL encoding.
Table 1.3 Used Symbols and URL Encoding
The engine of the World Wide Web is the application protocol that defines how Web
servers and clients exchange information using the HyperText Transfer Protocol NOTES
(HTTP). The first version of HTTP, HTTP/0.9, was part of the early World Wide
Web and was a very simple request/response protocol with limited capabilities that
could transfer only text files. The first widely used version was HTTP/1.0, which is a
more complete protocol that allows the transport of many types of files and resources.
The current version is HTTP/1.1, which expands HTTP/1.0’s capabilities with several
features that improve the efficiency of transfers and address many of the needs of the
rapidly growing modern World Wide Web.
The HyperText Transfer Protocol is a protocol specifically designed to allow
the transfer of HyperText Markup Language (HTML) documents. HTML is a tag
language used to create HyperText documents. HyperText documents include links to
other documents that contain additional information about the highlighted term or subject.
Such documents can contain other elements apart from text, such as graphic images,
audio and video clips, Java applets and even virtual reality worlds.
Overview of HTTP
HTTP is based on request-response activity. A client, running an application called a
browser, establishes a connection with a server and sends a request to the server in
the form of a request method. The server responds with a status line, including the
message’s protocol version and a success or error code, followed by a message
containing server information, entity information and possible body content.
An HTTP transaction is divided into the following four steps:
1. The browser opens a connection.
2. The browser sends a request to the server.
3. The server sends a response to the browser.
4. The connection is closed.
On the Internet, HTTP communication generally takes place over TCP connections.
The default port is TCP 80, but other ports can be used. This does not preclude HTTP
from being implemented on top of any other protocol on the Internet or on other
networks. HTTP only presumes a reliable transport; any protocol that provides such
guarantees can be used.
HTTP is a stateless protocol because it does not keep track of the connections.
To load a page including two graphics, for example, a graphic-enabled browser will
open three TCP connections: one for the page and two for the graphics. Most browsers,
however, are able to handle several of these connections simultaneously.
HTTP Operation
In most cases, the HTTP communication is initiated by the user agent requesting a
resource on the origin server. In the simplest case, the connection is established through
a single connection between the user agent and the origin server (see Figure 1.3).
Self-Instructional Material 11
Foundations for Internet
Programming
NOTES
#1 #2 #3
#3 #2 #1
HTTP Message
All the communication between devices using the HyperText Transfer Protocol takes
place via HTTP messages. There are only two types of messages: Requests and
Responses. Clients usually send requests and receive responses, while servers receive
requests and send responses. Intermediate devices, such as gateways or proxies may
send and receive both types of message.
HTTP General Message
All HTTP messages are text-based messages created to fit a message structure that
the standard calls the Generic Message Format.
HTTP messages consist of the following fields:
Message Types
A HTTP message can be either a client request or a server response. The following
string indicates the HTTP message type:
HTTP Message = Request/Response
Message Header
The HTTP message header field can be one of the following:
• General header
12 Self-Instructional Material • Request header
• Response header Foundations for Internet
Programming
• Entity header
• Message body
Message body can be referred to as entity body if there is no transfer coding. NOTES
Message body simply carries the entity body of the relevant request or response.
Message length indicates the length of the message body if it is included.
HTTP Request Message Format
HTTP requests are the means by which HTTP clients ask servers to take a particular
type of action, such as sending a file or processing user input (see Figure 1.5).
The structure of HTTP requests:
<request-line>
<general-headers>
<request-headers>
<entity-headers>
<empty-line>
[<message-body>]
[<message-trailers>]
Message Body
Each request message begins with a request line, containing three critical pieces of
information: the method (type of action) the client is requesting; the URI (Uniform
Resource Identifier) of the resource upon which the client wishes the action to be
performed, and the version of HTTP that the client is using. After the request line come
a set of message headers related to the request, followed by a blank line and then
optionally, the message body of the request.
• General Headers: General headers refer mainly to the message itself, as
opposed to its contents and are used to control its processing or provide the
recipient with extra information. They are not particular to either request or
response messages, so they can appear in either. They are likewise not specifically
relevant to any entity the message may be carrying.
• Request Headers: These headers convey to the server more details about the
nature of the client’s request and give the client more control over how the
request is handled. For example, special request headers can be used by the
client to specify a conditional request—one that is only filled if certain criteria
are met. Others can tell the server which formats or encodings the client is able
to process in a response message. Self-Instructional Material 13
Foundations for Internet • Entity keaders: These are headers that describe the entity contained in the
Programming
body of the request, if any.
HTTP Response Message Format
NOTES Each request message sent by an HTTP client to a server prompts the server to send
back a response message (see Figure 1.6).
The structure of HTTP response:
<status-line>
<general-headers>
<response-headers>
<entity-headers>
<empty-line>
[<message-body>]
[<message-trailers>]
Each response message starts with a status line that contains the server’s HTTP
version number and a numeric status code and text reason phrase that indicate the
result of processing the client’s request. The message then contains headers related to
the response, followed by a blank line and then the optional message body. Since
most HTTP requests ask for a server to return a file or other resource, many HTTP
responses carry an entity in the message body (see Figure 1.7).
• General Headers: General headers refer to the message itself and are not
specific to response messages or the entity in the message body. These are the
same as the generic headers that can appear in request messages (though certain
General headers: General
headers refer to the message
headers appear more often in responses and others are more common in
itself and are not specific to requests).
response messages or the • Response Headers: These headers provide additional data that expands upon
entity in the message body
the summary result information in the status line. The server may also return
extra result information in the body of the message, especially when an error
occurs, as discussed below.
• Entity Headers: These are headers that describe the entity contained in the
body of the response, if any. These are the same entity headers that can appear
in a request message, but they are seen more often in response messages. The
14 Self-Instructional Material
reason for this is simply that responses more often carry an entity than requests, Foundations for Internet
Programming
because most requests are to retrieve a resource.
NOTES
Space Space
Status Codes
Table 1.4 defines the various status codes that are generally displayed to the users.
Table 1.4 Status Codes
Self-Instructional Material 15
Foundations for Internet
Programming
NOTES
Method Definitions
Currently defined methods are as follows:
Safe and Idempotent Methods
Methods considered not to cause side effects are referred to as safe. Idempotent
methods are GET, HEAD, PUT and DELETE.
• OPTIONS: This method allows the client to determine the options or
requirements associated with a source or capabilities of a server without any
resource retrieval.
• GET: This method allows the client to retrieve the data that was determined by
the request URI.
• HEAD: This method allows the client to retrieve meta information about the
entity that does not require you to transfer the entity body.
• POST: The post function is determined by the server.
• PUT: This method is similar to the post method with one important difference:
The URI in post request identifies the resource that will handle enclosed entity.
• DELETE: This methods requests that the server delete the source determined
by the request URI.
• TRACE: This method allows the client to see how the message was retrieved
at the other side for testing and diagnostic purposes.
HTTP Message Headers
Much of the functionality in HTTP is actually implemented in the form of message
headers, which convey important details between clients and servers. Some headers
can appear in only HTTP requests, some in only HTTP responses and some in either
type of message (see Figure 1.9).
16 Self-Instructional Material
Foundations for Internet
Programming
Self-Instructional Material 17
Foundations for Internet HTTP Response Headers
Programming
The counterparts to request headers, response headers appear only in HTTP responses
(see Table 1.7). They provide additional data that expands upon the summary
NOTES information that is present in the status line at the beginning of each server reply. Many
of the response headers are sent only in response to the receipt of specific types of
requests, or even particular headers within certain requests.
Table 1.7 Response Headers
1.5 WWW
The World Wide Web or WWW is a global hypertext system that was initially developed
in 1989 by Tim Berners Lee at the European Laboratory for Particle Physics, CERN,
in Switzerland to facilitate an easy way of sharing and editing research documents
among a geographically dispersed group of scientists.
The WWW has a unique combination of flexibility, portability and user friendly
features that distinguish it from other features provided by the Internet.
Architecture of WWW
Figure 1.10 illustrates the architecture of WWW which supports the interoperability
design principle, assured by the implementation of compatible languages and protocols,
and enables access, exchange and processing of information among agents. The
evolution of the WWW technology supports maintainability and decentralization of
information systems.
Web Server
HyperText HyperText Uniform Hardware and
Markup Transfer Resource Software
Language Protocol Identifiers
(HTML) (HTTP) (URIs) Web Client
Web Hardware
Hardware and
and Software
Browser
Software
Web Browsers
Web browsers are HTTP client software programs that run on TCP/IP client computers
to access Web documents on Web servers. These browser programs retrieve hypertext
Web browsers: HTTP client documents and display them, and also implement many of the Web’s advanced features,
software programs that run such as caching (see Figure 1.12). Browsers used today support a wide variety of
on TCP/IP client computers media, allowing the Web to implement many different functions aside from simply
to access Web documents hypertext document transfer. Examples include displaying images, playing sounds and
on Web servers
implementing interactive programs.
Each browser usually consists of three parts, i.e., a controller, client protocol, and
interpreters. The controller receives input from the keyboard or the mouse and uses
client programs to access the document. After the document has been accessed, the
controller uses one of the interpreters to display the document on screen.
20 Self-Instructional Material
Web Servers Foundations for Internet
Programming
Web servers are computers that run special server software to allow them to provide
hypertext documents and other files to clients who request them. Millions of such
machines around the world now serve as a virtual, distributed repository of the enormous
NOTES
wealth of information that the Web represents.
Working of WWW
Following are the working phenomena of WWW:
• Viewing a Web page on the WWW normally begins either by typing the URL of
the page into a Web browser or by following a hyperlink to that page or resource.
• First, the server name portion of the URL is resolved into an IP address using
the global, distributed Internet database known as the domain name system.
• The browser then requests the resource by sending an HTTP request to the
Web server at that particular address.
• The HTML text of the page is requested first and parsed immediately by the
Web browser which will then make additional requests for images and any
other files that form a part of the page.
• Having received the required files from the Web server, the browser then renders
the page onto the screen as specified by its HTML, Cascading Style Sheets or
CSS and other Web languages. Any images and other resources are incorporated
to produce the on-screen Web page that the user sees.
Hypertext
Hypertext is the main concept that makes the WWW more than just another message
transfer system. The prefix ‘hyper’ usually means ‘above’ or ‘beyond’and thus hypertext
is like text, but goes beyond it in terms of functionality. The extra information in a
hypertext document is used to tell the computer program that displays the file to a user
how to format it. This information takes the form of special instructions that are
interspersed with the actual text of the document itself which are written according to
the syntax of a defining language. This addition of extra elements to the content of a
document is commonly called marking up the document.
The WWW hypertext documents use HyperText Markup Language (HTML).
HTML documents are as American Standard Code for Information Interchange or
ASCII text files, but are arranged using a special structure of HTML elements that
define the different parts of the document and how they should be displayed to the
user. Each element is described using special text tags that define it and its characteristics
(see Figure 1.13).
NOTES
Active Documents
In active documents the program or script runs at the client side. When a browser
requests an active document, the server sends a copy of the document or script. The Active documents: In active
document is then run on the client side. Active documents are sometimes referred to as documents the program or
client-side dynamic documents (see Figure 1.17). script runs at the client side
• JavaScript is interpreted and run by the client at the same time. The script is in
the source code (see Figure 1.18).
Intranet is the standard term used for a set of private computer networks operating
within an organization. The intranet network technologies are used to ease
communication between people or work groups of an organization and also to enhance
the data sharing capacity of an organization database. The intranets use standard network
hardware and software technologies, such as Ethernet, WiFi, TCP/IP, Web browsers
and Web servers. Technically, an organization’s intranet supports Internet access but it
is firewalled in such a secured way that the computers connected to its network cannot
be accessed directly from the outside. In several organizations, intranets are shielded
and safeguarded from unauthorized external access through a network gateway and
firewall. Basically, extranets which are the general extension to intranets releases this
firewall for providing organized and secured access to outsiders. Extranets broaden a
Self-Instructional Material 25
Foundations for Internet private network onto the Internet with distinctive specifications for Authentication,
Programming
Authorization and Accounting (AAA) protocol. Thus, an intranet is principally a
corporate productivity tool. Organization may permit access to off-site employees, if
required, through a virtual private network or via additional access methods by defining
NOTES
unique user authentication and encryption.
A simple intranet computer network system includes an internal e-mail system
and possibly a message board service. More advanced and sophisticated intranet
networks include Websites and companies databases in the form of news, forms and
employee’s personnel information. In addition, for e-mail and groupware applications,
an intranet usually integrates company’s internal Websites, documents and/or databases.
Technically, within an organization an intranet computer network uses Internet
Protocol (IP) technology for sharing information within functional systems or computers
and may include multiple Local Area Networks (LANs). One of the standard and
popular Internet protocols can be defined in an intranet, such as HTTP (HyperText
Transfer Protocol) for Web services, SMTP (Simple Mail Transfer Protocol) for
e-mail facilities and FTP (File Transfer Protocol) for easy exchange of information
from secured resources. Specific Internet technologies can be set for providing current
or advanced interfaces to legacy information systems that host corporate data of an
organization. Such an intranet is considered as a private analog of the Internet or as a
private extension of the Internet restricted to an organization.
Nowadays, intranets are uniquely set to provide relevant tools and applications
to enhance productivity in an organization, such as collaboration that assists while
working in groups and during teleconferencing, organizing corporate directories using
advanced sales and customer relationship management tools, and analysing project
management. Intranets are also widely used as platform to revolutionize corporate
culture, such as employees can converse over the key issues of their organization via
an intranet forum application which may give innovative ideas to management for
productivity, quality and other corporate issues.
Planning and Creation of Intranet
The intranet in an organization has strategic importance in the success and growth of
an organization. The following are some significant points for planning an intranet:
• Planning the objective and goals of the intranet.
• Specifying persons or departments accountable for the implementation and
management of the intranet.
• Specifying functional strategies, information architecture, page layouts and design
of the intranet.
• Determining implementation schedules and phase out of existing systems, if any.
• Defining and implementing security of the intranet.
• Ensuring it within legal boundaries and other constraints.
• Defining desired level of interactivity, for example wikis, online forms, etc.
26 Self-Instructional Material
• Checking the input of new data and updating of existing data so that it can be Foundations for Internet
Programming
centrally controlled or devolved.
Usually, intranets are considered as static sites. Fundamentally, they are shared drives
specifically set to operate on centrally stored documents. However, organizations are NOTES
maintaining their intranets in such a way that it has become a ‘communication hub’ for
their groups/employees and specifically support the feature ‘socializing’ intranets. The
authentic implementation includes the following steps:
Step 1: Securing senior management support and funding.
Step 2: Business requirements analysis.
Step 3: Identifying users’ information needs.
Step 4: Installation of Web server and user access network.
Step 5: Installation of required user applications on computers.
Step 6: Creation of document framework for the content to be hosted.
Step 7: User involvement in testing and promoting use of intranet.
Step 8: Ongoing measurement and evaluation, including through benchmarking against
other intranets.
Step 9: Selecting key personnel for maintaining the intranet and keeping content
up-to-date.
Intranet Development
While planning a secured intranet, the most important point is to assign the responsibility.
Depending on the size of organization, the responsibility can be assigned to single
employee or a group of employees who will further determine what content should be
published on the intranet and what technology will be used in the process. This intranet
team will consider the size, cost and functionality of the intranet. The following are
some universal considerations which must be considered when planning for an
organization intranet:
• Who is the primary audience of intranet? All employees? Or only certain
departments?
• What are the goals of intranet? Improved document access? Better collaboration?
Cut down on printing costs?
• How will the success of the intranet be measured? Check Your Progress
11. List the major components
• What types of documents and which corporate databases will be accessed? of WWW.
• What Web-based applications will be accessible from the intranet? 12. Define the term Web
browser.
• How will the site be structured? What will be on the homepage, the different
13. In how many categories can
main landing pages and sub-pages? the Web documents be
classified?
• Will everyone be allowed to publish content to the intranet or only certain
14. What are static documents?
employees?
15. State any three components
• Who will be in-charge of communicating editorial guidelines and maintaining required for setting up a
secure and reliable intranet.
editorial consistency?
Self-Instructional Material 27
Foundations for Internet Besides, the intranet team must address the basic technical questions for smooth
Programming
functioning of the intranet during the planning phase. Some of the significant ones are
as follows:
NOTES • Who will be in-charge of configuring and maintaining the Web server?
• Will the server and network be administered by in-house information technology
staff or by outside contractors?
• What security precautions (firewalls, security software) are taken to limit the
access to the intranet?
• How much network bandwidth will the intranet require?
• How will new applications be tested before being added to the intranet?
• What Content Management System (CMS) will be used to create and publish
content?
Check Your Progress • How will employees be trained on the CMS?
16. Fill in the blanks with
appropriate words.
• Who will be accountable for technical issues/questions about the CMS?
(a) The most important • How will the company back up the intranet data? How does intranet data fit
feature that improves into the company’s larger disaster recovery plan?
the efficiency of
operation of HTTP is After settling all these issues, the intranet team presents a proposed budget to the
___________.
executives’ in-charge. In bigger organizations, these may be the Chief Technical Officer
(b) The prefix
'___________' usually (CTO) and/or Chief Information Officer (CIO). In the intranet budget, the cost
means 'above' or projections for the following items must be included:
'beyond'.
(c) In a____________
• Web servers.
documents the program • People to administer servers (in-house or contractors).
or script is running at
the client side. • Web development and design (in-house or contractors).
(d) ______________ is the • Content management system.
standard term used for a
set of private computer • Application development (software and personnel).
networks operating
within an organization.
• Security hardware and software.
17. State whether the following • Long term maintenance costs.
statements are true or false.
(a) MAN covers
After the approval of the budget, the team can set up a safe and effective intranet.
geographical areas that
are larger than LAN but
Setting up an Intranet
smaller than WAN.
(b) It is always feasible to
For setting up a secure and reliable intranet, the following components are required:
maintain WWW without • Web server (hardware and software).
using the URLs.
(c) HTTP request headers
• Networked personal computers.
are used only in HTTP • Firewall hardware and software.
request messages and
serve a number of • Content Management Software (CMS).
functions in them.
• Other application software.
(d) HyperText is the main
concept that makes the In a Web server, the hardware helps in using the intranet Web server and depends
WWW more than just
on the size of the intranet, the content to be published and the number of people
another message transfer
system. accessing the intranet at any given time. The server software handles all requests for
files hosted on the server, finds the file and sends it off to the right computer.
28 Self-Instructional Material
Thus, development of intranet applications is a layered process. First, the Foundations for Internet
Programming
technical infrastructure should be created. Next the end solutions that attract users to
the technology must be employed. The tools that make intranet technology manageable
and provide more efficient development environments must be established.
NOTES
1.7 SUMMARY
Short-Answer Questions
1. Define the significance of the Internet.
2. List the major applications of the Internet.
3. Define the term HTTP.
4. What is URL encoding?
5. Write down the structure of HTTP Response message format.
6. Differentiate between HTTP general headers and HTTP request headers.
7. Define the significance of active documents in WWW.
8. What is an intranet?
9. What are the points that should be kept in mind while planning an intranet?
10. List the important components required for setting up an intranet.
Long-Answer Questions
1. What is an Internet? Describe the various features of Internet.
2. Explain the significance and utilities of HyperText protocol or HTTP with reference
to WWW.
3. What is URL encoding? Discuss the various symbols and characters used by
the URL.
Self-Instructional Material 31
Foundations for Internet 4. Describe the HTTP operation with the help of a diagram.
Programming
5. What are the request and statues lines? Explain with the help of a diagram.
6. Explain the term WWW and its architecture with the help of a diagram.
NOTES 7. Write a note on Web documents.
8. Discuss the important points associated with the planning and creation of intranet.
32 Self-Instructional Material
Internet Programming
UNIT 2 INTERNET PROGRAMMING Languages
LANGUAGES
NOTES
Structure
2.0 Introduction
2.1 Unit Objectives
2.2 Overview of Java
2.3 Features of Java
2.4 Lexical Issues
2.5 Strawberry Perl or Active Perl
2.6 Operators
2.6.1 The ? Operator
2.7 Control Statements
2.8 Practical Extraction and Reporting Language (Perl): An Introduction
2.8.1 Basic Structure of Perl
2.9 Starting a Perl Program
2.9.1 Documenting Programs
2.9.2 Debugging Programs
2.10 Perl Variables
2.11 CGI Environment Variables
2.12 Summary
2.13 Answers to ‘Check Your Progress’
2.14 Questions And Exercises
2.0 INTRODUCTION
In this unit, you will learn about the basics of the Internet programming languages, Java
and Perl. Java was developed as a platform independent language for consumer
electronic devices but later on it evolved as a preferred language for the Internet. Java
is platform independent language which means that the applications created in Java
can run on different operating systems. Java is a portable language that generates an
intermediate code, which is converted into machine code by Java Virtual Machine
(JVM). Various features of Java, such as simple, platform independent, portable, object
oriented, secure and robust enables to develop robust, portable and manageable
applications. A programming paradigm (also known as programming methodology)
describes the structure of a program. In other words, it determines how the instructions
are placed in a program. You will learn to create Java programs. Finally, you will learn
about the Perl programming language. You will also learn about basic Perl variables
and data types. A variable is a place to store a value, so you can refer to it or manipulate
it throughout your program. Perl has three types of variables, namely scalars,
arrays and hashes. You will also learn about CGI environment variables which is a
series of hidden values that the Web server sends to every CGI program you run.
Self-Instructional Material 33
Internet Programming
Languages 2.1 UNIT OBJECTIVES
After going through this unit, you will be able to:
NOTES • Explain the history and features of Java
• Discuss different data types and variables of Java
• Explain Java operators and their precedence
• Discuss the various control statements used in Java
• Explain the basic structure of Perl
• Describe how to start Perl programs
• Comprehend Perl variables
• Discuss CGI environment variables
If you already know C, you only have to make a little more effort to become a Java
expert. However, if you have learned C++, you have to unlearn a little before you
proceed to learn Java.
Java, which is an object oriented programming language is based on the concept
of an object. If you have some familiarity with an object oriented language, such as
Smalltalk or C++, much of Java will be familiar to you. Java is derived from C++, but
is slightly simplified with libraries and convenient for the Internet. It is the programming
language for the Internet environment. The Internet implies heterogeneous systems,
different network features, different windows libraries and different operating systems.
Java guarantees identical program behaviour on different platforms.
Java is an interpreted language. Java compiler complies the Java source code
to obtain an object code termed as bytecode in Java terminology. The Java interpreter
will interpret and run by the byte code at runtime.
Java is architectural neutral language. Architectural neutrality means that the
bytecode that is the output of the Java compiler will run on any processor and operating
system. You can compile a Java program to obtain the bytecode. This bytecode or
object code will run on any processor and operating system, provided a suitable
interpreter is available.
Java is portable as well. This means that Java provides the same Application
Programmer’s Interface (API) functions or library calls on each system. Java API
functions are the same for a programmer on Window 95, Windows NT or on Solaris
2.x. To port a program from one of these platforms to another, what the programmer
generally does is to recompile the program. However, due to the architectural neutrality
of Java, you do not even have to do that.
Why Java is Important to the Internet?
Java came to the forefront of programming with the help of the Internet. Consequently,
Java had a deep effect on the Internet. In addition to simplifying Web programming in
34 Self-Instructional Material
general, Java innovated a new type of networked program called the Applet. A Java Internet Programming
Languages
Applet is a small program embedded in a Web page which runs when that page is
browsed using a Web browser.
Java’s Magic: The Bytecode NOTES
You have just learned that the output of a Java compiler is not an executable code.
Rather, it is a bytecode. In Java bytecode is a highly optimized set of instructions
planned to be executed by the Java runtime system, which is referred to as the Java
Virtual Machine (JVM). A Java program executed by the JVM helps solve problems
associated with Web based programs. Since the JVM is in control, it can hold the
program and check it from generating side effects outside the system.
Java Buzzwords
As mentioned earlier, portability and security is the innovation of Java. Some additional
factors too played significant roles in moulding the final form of Java. The list of
buzzwords summed up by the Java team is as follows:
• Simplicity: Programmers find it easy to write applications as it avoids the use
of the concepts of C/C++, such as pointers, operator overloading, multiple
inheritance, etc. String manipulations can be implemented very easily without
any explicit concatenation procedure.
• Portability: Java is famous for its unique feature—platform independence
(architecture neutral). This means that a Java program compiled on one machine
could be ported to any other machine/operating system and executed without
any modifications. Thus, the class file, which is the result of compilation resides
on a DOS platform, can run on a UNIX platform unlike the .exe file of C/C++.
This is an important feature for which Java is preferred for the Internet
applications.
• Robust and Object Oriented: Java is a highly object oriented language where
reusability is of utmost importance. Java programs are very reliable on different
platforms with the special features of memory allocation and de-allocation, and
exception handling. Memory management, especially de-allocation, is taken
care of by the Java environment, which is not the case in C/C++, where
programmers have to deal with it explicitly with extra code. Exception handling
is a mechanism that helps the execution of a code, even if an error occurs at
runtime, by handling the exception.
Robustness is also achieved because Java is a strongly typed language. It
signifies that you must declare the variable type before you use it. This is different
from languages, such as PERL, JavaScript, etc., which are loosely typed.
• Multithreaded: Java with its multithreaded approach can run many programs
concurrently, thereby saving processor time. Synchronization of code is an added
feature of Java to run non-erroneous interactive applications.
• Distributed and Dynamic: Java is also popular for its distributed environment,
as it supports the Transmission Control Protocol/Internet Protocol (TCP/IP).
With Java, you can access a Uniform Resource Locator (URL) or a file on a
remote server in some other country with the same ease, as you can access a
file on your local system.
Self-Instructional Material 35
Internet Programming Java can also validate the code at runtime, which is more important for applets.
Languages
Therefore, it is feasible to dynamically connect the code in a secure and practical manner.
NOTES
2.3 FEATURES OF JAVA
Java inherits most of its features from the earlier object oriented languages like C++.
Various features of Java are:
• Compiled and interpreted.
• Platform independent and portable.
• Object oriented programming approach.
• Robust and secure.
• Simple and distributed.
• Small and familiar.
• Multithreaded and interactive.
• High performance.
• Dynamic and extensible.
Java Environment
The Java environment comprises a set of tools and classes that are used to run the
Java program. These tools are:
• Java development kit.
• Java standard library.
Java Development Kit
Java Development Kit (JDK) contains various tools used by the Java Runtime
Environment (JRE) that can be used to compile and interpret Java programs. The Java
Java Development Kit tools include Java compiler, Java interpreter, Java disassembler and Java debugger.
(JDK): It Contains various JRE is a software that is used to execute the Java program. The Java Development Kit
tools used by the Java (JDK) contains following tools to run and execute the Java programs:
Runtime Environment (JRE)
that can be used to compile • appletviewer allows you to run Java applets.
and interpret Java programs
• javac is a Java compiler that translates the Java source code into Javaclass
files or the bytecode files that can be interpreted by the java interpreter.
• java is a Java interpreter that executes various applications by interpreting
the bytecodes files.
• javah is used for including the C header files in a Java program.
• javap acts as a disassembler and is used to convert bytecode files into a
program source code.
• javadoc creates documentation of the Java source code files in the HTML
format from the comments available in the java source code.
• jdb is a java debugger that locates errors in a Java program.
Figure 2.1 shows the basic configuration of the Java tools that is used to process a
Java program.
36 Self-Instructional Material
javadoc Internet Programming
Java source HTML Languages
code documents
javac
NOTES
Java compiler
Output
Self-Instructional Material 37
Internet Programming Compile Interpreter
Languages
Source r Bytecode Machine
Code
JVM
NOTES Fig. 2.2 Execution of a Java Program
Literals
Literals are elements. They are used in an invariant way in a program. They are also
called constants. Literals could be numbers (numeric literals), characters or strings.
Literals: They are elements Numeric literal might be an integer, a floating point number or a Boolean. Integers
and used in an invariant way come in different formats depending on the base system used to represent that number.
in a program. They are also Decimal format (base 10), hexadecimal format (base 16) and octal format (base 8)
called constants and could
are the three commonly used formats. Decimal numbers appear as ordinary number
be number, characters or
strings with a leading 0x, or 0X in a program (For example: int y=0×7B; or int Y=0×7B;).
Octal numbers appear with a leading 0 (example: int y=0173;). Decimal numbers
appear as 173=0×7B=0173.
38 Self-Instructional Material
Floating point literals represent decimal numbers with a fractional part, such as Internet Programming
Languages
314.156. They can be represented in either standard or scientific notation. The numbers
314.156 can be expressed as 3.14156×102 in scientific notation. In a Java program
one can write it as:
int y=314.156; NOTES
or
int y=3.14156e2;
or
int y=3.14156E2;
Character literals represent 16-bit Unicode characters and appear within a pair
of simple quotes in a program. For example, char ch = ‘a’. Back slash (\) followed by
the character code represents special characters. The latter are control characters and
characters that cannot be printed.
The special characters that Java maintains are shown in the Table 2.1 that follows:
Table 2.1 Special Characters Supported by Java
String literals stand for many characters enclosed within a pair of double quotes:
For example: “Hello World”. In Java, string literals are implemented through a class
called String class.
Comments
Comments are used in a program for documentation purpose. Comments give clarity
to the source code. Java supports the following types of comments:
/* Some comment */ -This is the old C style comment.
// Some other comment -This is the C++ comments.
/** Another comment */ -This is same as the C style comment with
an extra benefit that it can be used with Java
automatic documentation tool ‘javadoc’ to
create automatic documentation from the
source code.
Self-Instructional Material 39
Internet Programming Separators
Languages
Separators are used to inform the Java compiler about how statements are grouped
together in the code. Table 2.2 shows the separators supported by Java.
NOTES Table 2.2 Separators Supported by Java
Java Keywords
Java keywords are reserved words and have special meaning for Java compilers.
They cannot be used as identifiers in a program. Java has a rich set of keywords,
which are listed as follows:
abstract continue for new switch
assert default goto package synchronized
boolean do if private this
break double implements protected throw
byte Else import public throws
case enum instanceof return transient
catch extends int short try
char final interface static void
class finally long strictfp volatile
const float native super while
2.6 OPERATORS
Java provides a rich operator environment. Most of the operators can be divided into
arithmetic operators, bitwise operators, relational operators and logical operators.
Arithmetic Operators Arithmetic operators: Used
in mathematical expressions
Arithmetic operators are used in mathematical expressions in the same way that in the same way that they
they are used in algebra. Table 2.5 lists the arithmetic operators. are used in algebra
Self-Instructional Material 41
Internet Programming Table 2.5 Arithmetic Operators
Languages
Java Operation Arithmetic Operator Java Expression
Addition + a + b
NOTES Subtraction - a - b
Multiplication * a * b
Division / a / b
Modulus % a % b
Increment ++ a ++
Decrement -- a --
Addition assignment += a + = b
Subtraction assignment -= a - = b
Multiplication assignment *= a * + b
Division assignment /| a / + b
Modulus assignment %+ a % =b
The operands of the arithmetic operators can be either numeric or char type but
not of Boolean type.
Bitwise Operators
Bitwise operators work on individual bits. As Java has the numeric data types as
signed twos complements, great care should be taken when dealing with negative
numbers, especially the shift operators sometimes give odd results with negative numbers.
They are summarized in the Table 2.6.
Table 2.6 Bitwise Operators
Description Operator
Addition +
Subtraction -
Multiplication *
Division /
Modulus %
Bitwise AND &
Bitwise OR |
Bitwise XOR ^
Left shift <<
Right shift >>
Zero-fill right shift >>>
Relational Operators
These operators are used to test for equality of expressions. They result in a true or
false. The relational operators are shown in Table 2.9. Relational Operators:
These operators are used to
Table 2.9 Relational Operators test for equality of
expressions
Relational Operator Java Operation Java Expression
= = Test for equality a = = b
! = Not equal to a ! = b
< Less than a < b
> Greater than a > b
< = Less than or equal to a < = b
> = Greater than or equal to a > = b
Self-Instructional Material 43
Internet Programming Table 2.10 Boolean Logical Operators
Languages
Logical Operator Java Operation Java Expression
& Logical AND a & b
NOTES | Logical OR a | b
!= Not equal to a ! = b
^ Logical XOR a ^ b
|| Short circuit OR a | | b
&& Short circuit AND a & & b
&= AND assignment a & = b
|= OR assignment a | = b
! Logical unary NOT a ! b
^ = XOR assignment a ^ = b
= = Equal to a = = b
?: Ternary if-then-else a ? b : c
Assignment Operator
The assignment operator is the single equal sign, =. It works in Java in the same way
in which it works in another language. The common form is:
var = expression;
Table 2.11 describes the various assignment operators in Java.
Table 2.11 Assignment Operator
Description Operator
Simple assignment =
Addition assignment +=
Subtraction assignment –=
Multiplication assignment *=
Division assignment /=
Modulus assignment %=
AND assignment &=
OR assignment |=
XOR assignment ^=
Division by Zero
Java does not allow integer division by zero. The operation 10/0 is an error and the
program will throw an ArithmeticException object. However, floating point division by
zero is permitted. The operations 10.0/0, 10/0.0., 10.0/0.0, etc., are allowed. The result
of this operation is infinity. The statement
System.out.println(10.0/0);
will print an output as follows:
Infinity
Operator Precedence
Operator precedence establishes the order in which operations are assessed. Each
Java operator has a precedence connected with it. The table that follows shows the
Java operators and their precedence. The operators at the topmost line have the
highest precedence. It means in an expression these operators will be evaluated first.
The operators in the bottommost line have the lowest precedence. Operators in the
same line have the same priority. Operations of the same precedence are evaluated
from left to right.
Self-Instructional Material 45
Internet Programming
Languages 2.7 CONTROL STATEMENTS
Generally, the statements in a program are executed one by one in the order in which
NOTES they are written. This type of execution is called sequential execution. If a programmer
wants to execute some statements even before other statements by surpassing the
order, he must temporarily transfer the control of execution. This can be achieved with
control statements like if, for, switch, etc. goto is a keyword in Java but its
Sequential execution: The
usage is prohibited keeping in view of the advantage of a structured programming
type of execution in which language.
the statements in a program
are executed one by one in
Selection Statements
the order in which they are
written
The if statement is the simplest form of condition called a single selection structure,
because it selects or ignores a single action. The syntax of if statement is:
if ( condition ) statement1;
else statement2;
int i, j;
// ….
if ( i < j ) i = 0;
else j = 0;
Iteration Statements
Java’s iterations statements are for, while and do...while. These statements
create what is commonly called loops.
for Loop
In for loop, execution of a group of statements is repeated a designated number of
times. The syntax of for loop is as follows:
for (initialization-expression; test-condition;
increment/decrement-operation)
{
46 Self-Instructional Material
statement1; Internet Programming
Languages
statement2;
.
.
. NOTES
statement n;
}
48 Self-Instructional Material
continue Statement Internet Programming
Languages
The continue statement skips the current iteration of a for, while or do
... while loop.
Program 3: A Java program to illustrate the continue statement. NOTES
class Continue
{
public static void main(String args[])
{
for( int i= 0;i<5;i++)
{
if(i= =2) continue;
System.out.println (“number:” +i);
}
System.out.println(“End of the for loop”);
}
}
Output of the program:
Number: 0
Number: 1
Number: 3
Number: 4
End of the for loop
return Statement
The last of the branching statements is the return statement. The return statement
exits from the current method and control flow returns to where the method was
invoked.
Perl was created by programmer Larry Wall. He wanted to have all the best features Check Your Progress
of other programming languages rolled into one and leave out all the useless functions. 6. What is Strawberry Perl?
Common Gateway Interface (CGI) is the means by which a Perl program, executed 7. What are the constituents of
on the Web server, communicates with a client (i.e., a user with a Web browser). Strawberry Perl?
Learning how to program in Perl is an essential skill for the one who wish to 8. List the operators used in
Java.
create advanced, interactive Websites. On the Web these days, Perl powers many
9. Which control statements
Web applications. Forms, search engines, guest books, electronic greetings, counters, are used in Java?
automatic page generation, mailing lists and databases are all made possible through
Perl and CGI. If you learn Perl and CGI, there are endless scope for you.
Perl is an interpreted programming language, as opposed to a compiled
programming language. ‘Interpreted’ means that a program written in Perl must be Perl: It is an interpreted
executed by the Perl interpreter every time it is executed. In contrast, a program programming language, as
written in a language, such as C or C++ must be ‘compiled’ once and then can be opposed to a compiled
directly executed later. programming language
Self-Instructional Material 49
Internet Programming Since Perl is an interpreted language, it is quite easy to write a program, run and
Languages test it, modify it, run it again, and so on, because recompiling after each change is not
necessary. However, this can be a limitation, as it requires that the Perl interpreter be
present every time the program is run. Most WWW servers have Perl installed, so
NOTES using Perl for CGI is usually possible.
2.8.1 Basic Structure of Perl
Perl is structurally similar to Pascal and C, so if you have got experience in these
programming languages, Perl should be fairly simple to pick up. There are small
differences that may cause problems if you are not attentive. A list of some of these
differences can be found at respective Websites, along with advice for programmers
coming to Perl from other languages.
Perl, like most languages, is made up of statements. These are instructions that
manipulate data, control the program flow, and handle input and output. Typically,
there is one statement per line. Each line in Perl must end with a semicolon. This is so
that the interpreter can differentiate between commands. Whitespace (spaces, tabs,
blank lines) is ignored and for this reason, use of whitespace to increase readability is
recommended. Anything from a ‘#’ character to the end of a line is treated as a
comment and also ignored.
Note: There is no syntax in Perl for multi-line comments, like there is in C (‘/*’ and ‘*/’).
Usage of ‘#’ is equivalent to the C++ usage of ‘//’.
50 Self-Instructional Material
The CGI.pm module is part of the standard library and has been since Perl Internet Programming
Languages
version 5.004. CGI.pm has a number of useful functions and features for writing CGI
programs and its use is preferred by the Perl community.
Let us see how to use a module in your CGI program. First you have to actually
include the module via the use command. This goes after the #!/usr/bin/ NOTES
Perl line and before any other code:
use CGI qw(:standard);
Note: We are not going to use CGI.pm but rather use CGI. The .pm is implied in the use
statement. The qw(:standard) part of this line indicates that we are importing the ‘standard’
set of functions from CGI.pm.
Now you can call the various module functions by typing the function name
followed by any arguments:
functionname(arguments)
If you are not passing any arguments to the function, you can omit the parentheses.
A function is a piece of code that performs a specific task; it may also be called
a subroutine or a method. Functions may accept optional arguments (also called Function: It is a piece of
parameters), which are values (strings, numbers and other variables) passed into the code that performs a specific
function for it to use. The CGI.pm module has many functions. For now we will start task; it may also be called a
subroutine or a method
by using these three:
header;
start_html;
end_html;
The header function prints out the ‘Content-type’ header. With no arguments,
the type is assumed to be ‘text/html’ start_html prints out the <HTML>, <HEAD>,
<TITLE> and <BODY> tags. It also accepts optional arguments. If you call
start_html with only a single string argument, it is assumed to be the page title.
Program 4: A program for printing an HTML file
print start_html(“Hello World”);
It will print out the following:
<HTML>
<HEAD>
<TITLE>Hello World</TITLE>
<HEAD>
<BODY>
You can also set the page colors and background image with start_html:
print start_html(-TITLE=>“Hello World”,
-BGCOLOR=>“#cccccc”, -TEXT=>“#999999”,
-BACKGROUND=>“bgimage.jpg”);
Note: With multiple arguments, you have to specify the name of each argument with -TITLE=>,
-BGCOLOR=>, etc. This example generates the same HTML as above, only the body tag indicates
the page colours and background image:
<BODY BGCOLOR=“#CCCCCC” TEXT=“#999999” BACKGROUND
=“bgimg.jpg”>
Self-Instructional Material 51
Internet Programming The end_html function prints out the closing HTML tags:
Languages
</BODY>
</HTML>
You can also declare several variables with the same my statement:
my ($foo, $bar, $blee);
You can omit the parentheses if you are declaring a single variable, however, a
list of variables must be enclosed in parentheses.
A scalar can hold data of any type, be it a string or a number. You can also use
scalars in double quoted strings:
my $fnord = 23;
my $blee = “The magic number is $fnord.”;
Now if you print $blee, you will get ‘The magic number is 23.’
Perl interpolates the variables in the string, replacing the variable name with the value
of that variable.
Let us try it out in a CGI program. Start a new program called scalar.cgi:
Program 6: A program to print scalar variables
#!/usr/bin/Perl -wT
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;
my $email = “fnord\@cgi101.com”;
my $url = “http://www.cgi101.com”;
print header;
print start_html(“Scalars”);
print <<EndHTML;
<H2>Hello</H2>
<P>
My e-mail address is $email, and my Web url is
<a href=“$url”>$url</A>.
</p>
EndHTML
print end_html;
Note: You may change the $email and $url variables to show your own e-mail address.
54 Self-Instructional Material
You will also notice the variable declarations: Internet Programming
Languages
my $email = “fnord\@cgi101.com”;
my $url = “http://www.cgi101.com”;
Notice that the @ sign in the e-mail address is preceded by a backslash. This is NOTES
because the @ sign means something special to Perl — just as the dollar sign indicates
a scalar variable, the @ sign indicates an array, so if you want to actually use special
characters like @, $ and % inside a double quoted string, you have to precede them
with a backslash (\).
A better way to do this would be to use a single quoted string for the e-mail
address:
my $email = ‘[email protected]’;
Single quoted strings are not interpolated the way double quoted strings are, so
you can freely use the special characters $, @ and % in them. However, this also
means you cannot use a single quoted string to print out a variable, because:
print ‘$fnord’;
It will print the actual string ‘$fnord’ . . . not the value stored in the variable
named $fnord.
Arrays
An array stores an ordered list of values. While a scalar variable can only store one
value, an array can store many. Perl array names are prefixed with an @ sign. Here is
an example:
my @colors = (“red”,”green”,”blue”);
Each individual item (or element) of an array are referred by its index number.
Array indices start with 0, so to access the first element of the array @colors you
use $colors[0]. Notice that when you are referring to a single element of an
array, you prefix the name with $ instead of @. The $ sign again indicates that it is a
single (scalar) value, the @ sign means you are talking about the entire array.
If you want to loop through an array, printing out all of the values, you could
print each element one at a time:
my @colors = (“red”,”green”,”blue”);
print “$colors[0]\n”; # prints “red”
print “$colors[1]\n”; # prints “green”
print “$colors[2]\n”; # prints “blue”
/pattern/ is a regular expression for the pattern you are looking for. It can be a
plain string, such as /Box kite/ or a complex regular expression pattern.
/pattern/ will match partial strings inside each array element. To match
the entire array element, use /^pattern$/, which anchors the pattern match to
the beginning (^) and end ($) of the string.
Sorting Arrays
You can do an alphabetical (ASCII) sort on an array of strings using the sort function:
my @colors = (“cyan”, “magenta”, “yellow”, “black”);
my @colors2 = sort(@colors);
You can invert the order of the array with the reverse function:
my @colors = (“cyan”, “magenta”, “yellow”, “black”);
@colors = reverse(@colors);
@colors is now (“black”, “yellow”, “magenta”, “cyan”).
Self-Instructional Material 57
Internet Programming To do a reverse sort, use both functions:
Languages
my @colors = (“cyan”, “magenta”, “yellow”, “black”);
@colors = reverse(sort(@colors));
@colors is now (“yellow”, “magenta”, “cyan”, “black”).
NOTES
Joining Array Elements into a String
You can merge an array into a single string using the join function:
my @colors = (“cyan”, “magenta”, “yellow”, “black”);
my $colorstring = join(“, “,@colors);
This joins @colors into a single string variable ($colorstring), with
each element of the @colors array combined, and separated by a comma and a
space. In this example $colorstring becomes ‘cyan, magenta, yellow,
black’.
You can use any string (including the empty string) as the separator. The separator
is the first argument to the join function:
join(separator, list);
The opposite of join is split, which splits a string into a list of values.
Environment variables are a series of hidden values that the Web server sends to every
CGI program you run. Your program can parse them and use the data they send.
Environment variables are stored in a hash named %ENV(refer Table 2.12).
Table 2.12 Environment Variables
Key Value
DOCUMENT_ROOT The root directory of your server.
HTTP_COOKIE The visitor's cookie, if one is set.
HTTP_HOST The hostname of the page being attempted.
HTTP_REFERER The URL of the page that called your program.
HTTP_USER_AGENT The browser type of the visitor.
‘on’ if the program is being called through a
HTTPS
secure server.
PATH The system path your server is running under.
QUERY_STRING The query string.
REMOTE_ADDR The IP address of the visitor.
The hostname of the visitor (if your server has
REMOTE_HOST reverse-name-lookups on; otherwise this is the IP
address again).
The port the visitor is connected to on the Web
REMOTE_PORT
server.
The visitor's username (for .htaccess protected
REMOTE_USER
pages).
REQUEST_METHOD GET or POST
The interpreted pathname of the requested
REQUEST_URI
document or CGI (relative to the document root).
SCRIPT_FILENAME The full pathname of the current CGI.
The interpreted pathname of the current CGI
SCRIPT_NAME
(relative to the document root).
SERVER_ADMIN The e-mail address for your server's Webmaster.
Your server's fully qualified domain name (e.g.,
SERVER_NAME
www.cgi101.com).
SERVER_PORT The port number your server is listening on.
The server software you are using (e.g., Apache
SERVER_SOFTWARE
1.3).
58 Self-Instructional Material
Some servers set other environment variables as well, check your server Internet Programming
Languages
documentation for more information. Notice that some environment variables give
information about your server and will never change (such as, SERVER_NAME and
SERVER_ADMIN), while others give information about the visitor and will be different
every time someone accesses the program. NOTES
Not all environment variables get set. REMOTE_USER is only set for pages in
a directory or subdirectory that is password protected via a .htaccess file. Even then,
REMOTE_USER will be the username as it appears in the .htaccess file; it is not the
person’s e-mail address. There is no reliable way to get a person’s e-mail address,
short of asking them for it with a Web form.
You can print the environment variables the same way you would any hash
value: Check Your Progress
print “Caller = $ENV{HTTP_REFERER}\n”; 15. Fill in the blanks with
appropriate words.
Let us try printing some environment variables. Start a new file named env.cgi: (a) The Java ___________
comprises a set of tools
Program 7: A program to print environment variables and classes that are used
#!/usr/bin/Perl -wT to run the Java program.
These tools are:
use strict;
(b) The only operation that
use CGI qw(:standard); is possible on string is
use CGI::Carp qw(warningsToBrowser fatalsToBrowser); the ______________
operation.
print header; (c) ________________
print start_html(“Environment”); means that a program
written in Perl must be
foreach my $key (sort(keys(%ENV))) executed by the Perl
{ interpreter every time it
is executed.
print “$key = $ENV{$key}<br>\n”;
(d) __________________ is
} only set for pages in a
print end_html; directory or
subdirectory that is
password protected via
Referring Page .ht access file.
16. State whether the following
When you click on a hyperlink on a Web page, you are being referred to another statements are true or false.
page. The Web server for the receiving page keeps track of the referring page and you (a) A prefix increment/
can access the URL for that page via the HTTP_REFERER environment variable. decrement operation
takes effect prior to the
Program 8: A program that illustrates HTTP referrer evaluation of the
#!/usr/bin/Perl -wT expression in which it is
appearing.
use CGI qw(:standard);
(b) Every integer literal in a
use CGI::Carp qw(warningsToBrowser fatalsToBrowser); program does not have a
default data type
use strict;
associated with it.
print header; (c) A scalar can hold data of
print start_html(“Referring Page”); any type, be it a string
or a number.
print “Welcome, I see you’ve just come from
(d) The key
$ENV{HTTP_REFERER}!<p>\n”; SERVER_PORT has the
print end_html; value as the port the
visitor is connected to
on the Web server.
Self-Instructional Material 59
Internet Programming
Languages 2.12 SUMMARY
Self-Instructional Material 61
Internet Programming 8. The various operators used in Java are:
Languages
• Arithmetic operators.
• Bitwise operators.
• Relational operators.
NOTES
9. The various control statements used in Java are:
• Selection statements.
• Iterative statements.
• Jump statements.
10. Perl was created by programmer Larry Wall.
11. A good first step in debugging is to use the CGI::Carp module in your program.
12. A comment in Perl is preceded by the # sign; anything app earing after the # is a
comment.
13. Perl has three types of variables, namely scalars, arrays and hashes.
14. Environment variables are a series of hidden values that the Web server sends to
every CGI program you run. Your program can parse them and use the data they
send.
15. (a) Environment, (b) Concatenation, (c) Interpreted, (d) REMOTE_USER.
16. (a) True, (b) False, (c) True, (d) False.
Short-Answer Questions
1. List the various Java keywords.
2. Distinguish between valid and invalid Java identifiers.
3. What is a Java token set?
4. Write some of the important features of Java programming language.
5. What are the components of Java development kit?
6. What is the difference between Java variables and Java literals?
7. What is the basic structure of Perl?
8. Name the add-on modules of Perl.
9. What are CGI environment variables?
Long-Answer Questions
1. Explain the different data types used in Java.
2. Discuss the significance of typecasting and type conversion.
3. Explain the various Java operators and operator precedence.
4. What are the various control statements? Explain each with their syntax.
5. Explain the automatic type promotion in expressions with the help of example.
6. Explain the basic structure of Perl.
7. Discuss the add-on modules of Perl.
8. Explain CGI environment variables with the help of examples.
62 Self-Instructional Material
Internet Scripting Languages
UNIT 3 INTERNET SCRIPTING
LANGUAGES
NOTES
Structure
3.0 Introduction
3.1 Unit Objectives
3.2 JavaScript
3.3 VBScript: An Introduction
3.3.1 VBScript in HTML
3.3.2 VBScript Data Types
3.3.3 Functions in VBScript
3.4 Other Scripting Languages and I/O Streaming
3.4.1 I/O Streaming
3.4.2 OutputStream Class
3.5 Applets
3.5.1 Applets and Web Pages
3.5.2 Limitations of Applets
3.5.3 Applet Basics
3.5.4 The Applet Class
3.6 Socket Programming
3.6.1 Using TCP/IP Sockets
3.6.2 Using UDP Sockets
3.7 Looking Up Internet Address
3.7.1 IPv4 Addressing
3.7.2 Classification of IPv4 Addresses
3.8 E-Mail Client
3.8.1 User Agent
3.8.2 Message Transfer Agent
3.8.3 E-Mail Message Format
3.9 Web Page Retrieval
3.10 Remote Method Invocation
3.10.1 Java Architecture RMI
3.10.2 RMI Architecture Layers
3.11 Summary
3.12 Answers to ‘Check Your Progress’
3.13 Questions and Exercises
3.0 INTRODUCTION
In this unit, you will learn about the basics of the Internet scripting languages, such as
JavaScript and VBScript. JavaScript is an object oriented scripting language which
enables programmatic access to objects within the client application and other
applications. ‘JavaScript’ is a trademark of Sun Microsystems. It was used under
license for technology invented and implemented by Netscape Communications and
current entities, such as the Mozilla Foundation. The primary use of JavaScript is to
write functions that are embedded or included from HTML pages and interact with the
Document Object Model (DOM) of the page. VBScript is a scripting language or
more specifically a scripting environment that can enhance HTML Web pages and
makes them more active than a simple static display.
Self-Instructional Material 63
Internet Scripting Languages You will learn about applets which is a small Java program and is much more
focused in scope than a full-fledged Java application. Applets are not given access to
a local machine’s file system. Thus, applet can neither read a file from the local machine,
nor it can save a file on the local system. The Applet class, which is in the java.awt.applet
NOTES package, inherits the properties of the Panel class, which is in java.awt package.
Finally, you will learn about Remote Method Invocation (RMI) which is a part of Java
Development Kit (JDK). It allows to develop distributed application. Distributed
systems require computations that are running in different address spaces, particularly
on different machines, to be able to communicate between one another.
3.2 JAVASCRIPT
JavaScript is the scripting language of the Web. JavaScript is used in millions of Web
pages to add functionality, validate forms, detect browsers, and much more.
JavaScript is an object oriented scripting language which enables programmatic
JavaScript: It is the access to objects within both the client application and other applications. It is primarily
scripting language of the used in the form of client-side JavaScript, implemented as an integrated component of
Web. JavaScript is used in the Web browser, allowing the development of enhanced user interfaces and dynamic
millions of Web pages to
add functionality, validate Websites. JavaScript is a dialect of the ECMAScript standard and is characterized as
forms, detect browsers, and a dynamic, weakly typed, prototype-based language with first-class functions.
much more JavaScript was influenced by many languages and was designed to look like Java, but
to be easier for non-programmers to work with.
JavaScript was originally developed by Brendan Eich of Netscape under the
name Mocha, which was later renamed to Live Script, and finally to JavaScript. The
change of name from LiveScript to JavaScript roughly coincided with Netscape adding
support for Java technology in its Netscape Navigator Web browser. JavaScript was
first introduced and deployed in the Netscape browser version 2.0B3 in December
1995. JavaScript, despite the name, is essentially unrelated to the Java programming
language even though the two do have superficial similarities. Both languages use
syntaxes influenced by that of C syntax, and JavaScript copies many Java names and
naming conventions. The language’s name is the result of a co-marketing deal between
Netscape and Sun, in exchange for Netscape bundling Sun’s Java runtime with their
64 Self-Instructional Material
then-dominant browser. The key design principles within JavaScript are inherited from Internet Scripting Languages
the Self and Scheme programming languages.
How Script Works?
Use in Web Pages: The primary use of JavaScript is to write functions that are NOTES
embedded in or included from HTML pages and interact with the Document Object
Model (DOM) of the page. Some simple examples of this usage are:
• Opening or popping up a new window with programmatic control over the size,
position, and attributes of the new window, i.e., whether the menus, toolbars,
etc. are visible.
• Validation of Web form input values to make sure that they will be accepted
before they are submitted to the server.
• Changing images as the mouse cursor moves over them. This effect is often
used to draw the user’s attention to important links displayed as graphical
elements.
Because JavaScript code can run locally in a user’s browser (rather than on a
remote server) it can respond to user actions quickly, making an application feel more
responsive. Furthermore, JavaScript code can detect user actions which HTML alone
cannot, such as individual keystrokes. Applications, such as Gmail take advantage of
this. The user-interface logic is written in JavaScript and JavaScript dispatches requests
for information (such as the content of an e-mail message) to the server. A JavaScript
engine (also known as JavaScript interpreter or JavaScript implementation) is an
interpreter that interprets JavaScript source code and executes the script accordingly.
A Web browser is by far the most common host environment for JavaScript. Web
browsers typically use the public API to create “host objects” responsible for reflecting
the DOM into JavaScript. The Web server is another common application of the
engine. A JavaScript Webserver would expose host objects representing an HTTP
request and response objects, which a JavaScript program could then manipulate to
dynamically generate Web pages.
A minimal example of a standards-conforming Web page containing JavaScript
(using HTML 4.01 syntax) would be:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN”
“http://www.w3.org/TR/html4/strict.dtd”>
<html>
<head><title>simple page</title></head>
<body>
<script type=”application/javascript”>
document.write(‘Hello World!’);
</script>
<noscript>
<p>Your browser either does not support JavaScript,
or you have JavaScript turned off.</p>
</noscript>
</body>
</html>
Self-Instructional Material 65
Internet Scripting Languages Since JavaScript is the only language that the most popular browsers share
support for, it has become a target language for many frameworks in other languages,
even though JavaScript was never intended to be such a language. Despite the
performance limitations inherent to its dynamic nature, the increasing speed of JavaScript
NOTES engines have made the language a surprisingly feasible compilation target.
Uses Outside Web Pages
Outside the Web, JavaScript interpreters are embedded in a number of tools. Each of
these applications provides its own object model which provides access to the host
environment, with the core JavaScript language remaining mostly the same in each
application.
• ActionScript, the programming language used in Adobe Flash, is another
implementation of the ECMAScript standard.
• Apple’s Dashboard Widgets, Microsoft’s Gadgets, Yahoo! Widgets, Google
Desktop Gadgets, Serence Klipfolio are implemented using JavaScript.
• The Mozilla platform, which underlies Firefox and some other Web browsers,
uses JavaScript to implement the Graphical User Interface (GUI) of its various
products.
• Adobe’s Acrobat and Adobe Reader (formerly Acrobat Reader) support
JavaScript in PDF files.
• Tools in the Adobe Creative Suite, including Photoshop, Illustrator, Dreamweaver
and InDesign, allow scripting through JavaScript.
• The Qt C++ toolkit includes a QtScript module to interpret JavaScript, analogous
to javax.script.
• OpenOffice.org office application suite allows for JavaScript as one of its scripting
languages.
• Adobe Integrated Runtime is a JavaScript runtime that allows developers to
create desktop applications.
• Some high-end Philips universal remote panels, including TSU9600 and
TSU9400, can be scripted using JavaScript.
• Sphere is an open source and cross platform computer program designed
primarily to make role-playing games that use JavaScript as a scripting language.
• The open-source Re-Animator framework allows developing 2D sprite-based
games using JavaScript and XML.
• Methabot is a Web crawler that uses JavaScript as scripting language for custom
filetype parsers and data extraction using E4X.
• Unity game engine supports three scripting languages: JavaScript, C#, and Boo.
• DX Studio (3D engine) uses the SpiderMonkey implementation of JavaScript
for game and simulation logic.
Debugging
Within JavaScript, access to a debugger becomes invaluable when developing large,
non-trivial programs. Because there can be implementation differences between the
various browsers (particularly within the Document Object Model) it is useful to have
access to a debugger for each of the browsers that a Web application targets. Script
debuggers are available for Internet Explorer, Firefox, Safari, Google Chrome and
Opera.
66 Self-Instructional Material
Three debuggers are available for Internet Explorer: Microsoft Visual Studio is Internet Scripting Languages
the richest of the three, closely followed by Microsoft Script Editor (a component of
Microsoft Office), and finally the free Microsoft Script Debugger which is far more
basic than the other two. The free Microsoft Visual Web Developer Express provides
a limited version of the JavaScript debugging functionality in Microsoft Visual Studio. NOTES
Web applications within Firefox can be debugged using the Firebug add-on, or
the older Venkman debugger. Firefox also has a simpler built-in Error Console, which
logs and evaluates JavaScript. It also logs CSS errors and warnings. Opera includes a
richer set of tools called DragonFly. WebKit’s Web Inspector includes a JavaScript
debugger in Apple’s Safari. Some debugging aids are themselves bits of JavaScript
code built to run on the Web. Web development bookmarklets and Firebug Lite
provide variations on the idea of the cross-browser JavaScript console. Since
JavaScript is interpreted, loosely-typed, and may be hosted in varying environments,
each incompatible with the others, a programmer has to take extra care to make sure
the code executes as expected in as wide a range of circumstances as possible and
that functionality degrades gracefully when it does not.
What can a JavaScript do?
• JavaScript gives HTML Designers a Programming Tool - HTML authors
are normally not programmers, but JavaScript is a scripting language with a
very simple syntax. Almost anyone can put small ‘snippets’ of code into their
HTML pages.
• JavaScript can put Dynamic Text into an HTML Page - A JavaScript
statement like this: document.write(“<h1>” + name + “</h1>”)
can write a variable text into an HTML page.
• JavaScript can React to Events - A JavaScript can be set to execute when
something happens, like when a page has finished loading or when a user clicks
on an HTML element.
• JavaScript can Read and Write HTML Elements - A JavaScript can read
and change the content of an HTML element.
• JavaScript can be Used to Validate Data - A JavaScript can be used to
validate form data before it is submitted to a server. This saves the server from
extra processing.
• JavaScript can be Used to Detect the Visitor’s Browser - A JavaScript
can be used to detect the visitor’s browser, and - depending on the browser -
load another page specifically designed for that browser.
• JavaScript can be Used to Create Cookies - A JavaScript can be used to
store and retrieve information on the visitor’s computer.
JavaScript and Java
A common misconception is that JavaScript is similar or closely related to Java; this is
not so. Both have a C-like syntax, are object oriented, are typically sandboxed and
are widely used in client-side Web applications, but the similarities end there. Java has
static typing; JavaScript’s typing is dynamic (meaning a variable can hold an object of
any type and cannot be restricted). Java is loaded from compiled bytecode; JavaScript
is loaded as human-readable code. C is their last common ancestor language.
Self-Instructional Material 67
Internet Scripting Languages Nonetheless, JavaScript was designed with Java’s syntax and standard library
in mind. In particular, all Java keywords are reserved in JavaScript, JavaScript’s
standard library follows Java’s naming conventions, and JavaScript’s Math and Date
classes are based on those from Java 1.0.
NOTES The following is the simple example of a JavaScript program:
Program 1: A program to demonists ate <script> tag
<html>
<body>
<script type=”text/javascript”>
document.write(“This is my first JavaScript!”);
</script>
</body>
</html>
Output of the program:
This is my first JavaScript!
The HTML <script> tag is used to insert a JavaScript into an HTML page.
Put a JavaScript into an HTML Page
Program 2: A program shows how to use JavaSript to write text on a Web page:
<html>
<body>
<script type=”text/javascript”>
document.write(“Hello World!”);
</script>
</body>
</html>
Output of the program:
Hello World!
Scripts in <head> and <body>
You can place an unlimited number of scripts in your document, so you can have
scripts in both the body and the head section.
<html>
<head>
<script type=”text/javascript”>
....
</script>
</head>
<body>
<script type=”text/javascript”>
....
</script>
</body>
68 Self-Instructional Material
JavaScript Statements: JavaScript is a sequence of statements to be executed Internet Scripting Languages
by the browser. A JavaScript statement is a command to a browser. The purpose of
the command is to tell the browser what to do. This JavaScript statement tells the
browser to write “Hello Dolly” to the Web page:
document.write(“Hello Dolly”); NOTES
It is normal to add a semicolon at the end of each executable statement. Most
people think this is a good programming practice, and most often you will see this in
JavaScript examples on the Web. The semicolon is optional (according to the JavaScript
standard), and the browser is supposed to interpret the end of the line as the end of the
statement. Because of this you will often see examples without the semicolon at the end.
Note: Using semicolons makes it possible to write multiple statements on one line.
This is a heading
This is a paragraph.
This is another paragraph.
The example above is not very useful. It just demonstrates the use of a block.
Normally a block is used to group statements together in a function or in a condition
(where a group of statements should be executed if a condition is met).
JavaScript Comments
JavaScript comments can be used to make the code more readable. Comments can
be added to explain the JavaScript, or to make the code more readable. Single line
comments start with //.
Self-Instructional Material 69
Internet Scripting Languages Because VBScript is an active scripting language hence it brings active scripting
to a wide variety of environments, including Web client scripting in Microsoft Internet
Explorer and Web server scripting in Microsoft Internet Information Service (IIS).
The basic concepts of VBScript are common to most programming languages.
NOTES VBScript interacts with the host applications using Windows script. With
Windows script, browsers and other host applications do not require special integration
code for each scripting component. Windows script enables a host to compile scripts,
obtain and call entry points and manage the namespace available to the developer.
VBScript can also be used to create applications that run directly on a workstation
running Microsoft Windows. The simplest example is a script that makes use of the
Windows Script Host (WSH) environment. Such a script is usually in a standalone file
with the file extension .vbs. The script can be invoked in two ways. Wscript.exe is
used to display output and receive input through a GUI, such as dialog and input
boxes. Cscript.exe is used in a command line environment.
Since the language of VBScript is modelled on Visual Basic hence it can be
analysed using the analogous categories, such as procedures, control structures,
constants, variables, user interaction, array handling, date/time functions, error handling,
mathematical functions, objects, regular expressions, string manipulation, etc.
In VBScript, a ‘procedure’ is the most important construct and is used to separate
code into smaller modules. The function in VBScript returns a result in an assignment
statement. Parameters are positional and can be passed by value or by reference.
Control structures consist of the standard iterative and conditional Do loops, If-
Then-Else and Case statements. Besides these, there are some additional complex
variants, such as ElseIf and nested control structures. There are a large number of
constants, such as ‘True’ and ‘False’ for logical values, vbOKCancel and vbYesNo
for MsgBox codes, vbBlack and vbYellow for color values, vbCR for the
carriage return character, etc.
By default, a variable is a well-located placeholder and refers to the memory
location in a computer where the program information is stored or can be stored
which may change when the script is running. In VBScript, constantly the variables are
of one fundamental type, i.e., ‘Variant’ type. The user interaction is possible using the
functions MsgBox and InputBox which display a simple dialog box format for messages
and input. VBScript can be used in combination with HTML, for example, in an
HTML Application.
The code modules are supported through the <script> and </script>
tag. Each script section forms an independent code module that may have its own
variables, functions and subroutines. The forms are created using the <form> and
</form> tag and they are not visible as separate windows in the application. The
forms are ways to group controls together for the purpose of addressing their properties
and methods in code or to submit data to back-end process.
3.3.1 VBScript in HTML
VBScript is a scripting language or more specifically a scripting environment that can
enhance HTML Web pages and makes them more active than a simple static display.
VBScript is inserted into HTML, between standard <script> and </script>
tags. Use the type attribute in the <script> tag to define the scripting language
‘text/vbscript’:
70 Self-Instructional Material
<html> Internet Scripting Languages
<body>
<script type=”text/vbscript”>
...
</script> NOTES
</body>
</html>
Internet explorer will interpret and execute the VBScript code between the
<script> and </script> tags. As already mentioned VBScript is not a standard
HTML language. VBScript is used in the Internet explorer only for learning purpose.
When VBScript is used on a Web server in an ASP page, the statement
response.write() produces output. When we use the Internet explorer for
testing VBScript, we use document.write() to produce output.
Program 3: A program that shows the use of document write()
<html>
<body>
<script type=”text/vbscript”>
document.write(“Hello World!”)
</script>
</body>
</html>
Output of the program:
Variables
In VBScript, variables are used to hold values or expressions. Variables are named
storage locations that can contain data that can be modified while script is running. A
variable can have a short name, like x or a more descriptive name, like car name or
City. Rules for VBScript variable names are as follows:
• Must begin with a letter, i.e., an alphabetic character.
• Cannot contain a period (.).
• Cannot exceed 255 characters.
• Must be unique in the scope in which it is declared.
In VBScript, all variables are of type variant that can store different types of
data.
Self-Instructional Material 71
Internet Scripting Languages 3.3.2 VBScript Data Types
VBScript has only one data type known as variant. A variant is a special kind of data
type that can contain different kinds of information, depending on how it is used.
NOTES Because variant is the only data type in VBScript, it is also the data type returned by
all functions in VBScript. At its simplest, a variant can contain either numeric or string
information.
Variant Subtypes
Beyond the simple numeric or string classifications, a variant can have other types as
subtypes. For example, you can have numeric information that represents a date or a
time. When used with other date or time data, the result is always expressed as a date
or a time. These different categories of information that can be contained in a variant
are called subtypes. Table 3.1 shows subtypes of data that a variant can contain.
Table 3.1 Subtypes of Data that a Variant can Contain
Subtype Description
Empty Variant is uninitialized. Value is 0 for numeric variables or a
zero-length string ("") for string variables.
Null Variant intentionally contains no valid data.
Boolean Contains either True or False.
Byte Contains integer in the range 0 to 255.
Integer Contains integer in the range -32,768 to 32,767.
Currency -922,337,203,685,477.5808 to 922,337,203,685,477.5807.
Long Contains integer in the range -2,147,483,648 to 2,147,483,647.
Single Contains a single precision, floating-point number in the range
-3.402823E38 to -1.401298E-45 for negative values;
1.401298E-45 to 3.402823E38 for positive values.
Double Contains a double precision, floating point number in the
range -1.79769313486232E308 to -4.94065645841247E-324
for negative values; 4.94065645841247E-324 to
1.79769313486232E308 for positive values.
Date(Time) Contains a number that represents a date between January 1,
100 to December 31, 9999.
String Contains a variable length string that can be up to
approximately 2 billion characters in length.
Object Contains an object.
Error Contains an error number.
Self-Instructional Material 75
Internet Scripting Languages Server-side scripting is thus defined as ‘Web server technology in which the
user’s request is fulfilled by running a script directly on a Web server to generate
dynamic Web pages’, i.e., a server-side script runs on the server rather than your
computer. When you visit a Website, the script will create the Web page on the fly
NOTES (dynamically). Dynamic Websites are becoming very popular because they can be
easily maintained. Websites with server-side scripts can typically be updated right on
the server. The files themselves do not change, as they only contain the scripts. Popular
server-side scripting languages include Perl, PHP, ASP, JSP, Ruby, ColdFusion and
Python. Many server-side scripting languages are cross-platform and open for anyone
to use. Specialized scripting languages include the following:
PHP: PHP is a server side HTML embedded scripting language that you can
use to create dynamic Web pages. It includes predefined functions that create, open,
PHP: PHP is a server side
read, write and close files stored on the server. You can create XML-based Web
HTML embedded scripting applications using PHP.
language that you can use Some browsers, such as Netscape Communicator 4.x series do not contain
to create dynamic Web
pages
XML parser. PHP overcomes this problem by supporting XML parsing. PHP provides
a Document Object Model (DOM) to access XML elements, an XML extension and
an eXtensible Stylesheet Language (XSL) processor to support XML parsing.
Perl or Practical Extraction and Report Language: This is a popular string
processing language for writing small scripts for system administrators and Website
maintainers.
Hypertalk: It is another example. It is the underlying scripting language of
HyperCard.
Lingo: It is the scripting language of Macromedia Director which is an authoring
system for develop high performance multimedia content and applications for CDs,
DVDs and the Internet.
AppleScript: A scripting language for the Macintosh allows the user to send
commands to the operating system to carry out complex data operations, for example
open applications.
3.4.1 I/O Streaming
Java I /O package contains many classes, each with a variety of member data stream
and methods. The Java I/O model is based on the concept of input output stream. A
stream uses an abstraction that either produces or consumes information. A stream is
a sequential flow of bytes from a source or to a destination. The input devices may
comprise a keyboard, files, memory and the Internet, etc., and output devices may
include monitor and files, etc.
The InputStream class is an abstract class that serves as the base class for
all other input streams and defines a basic interface for reading streamed bytes of
information. The InputStream defines three different read ( ) methods for
reading input data in various ways and their signatures are given as follows:
• int read( )
• int read(byte b[ ])
• inte read(byte b[ ], int off, int len)
Java input stream classes and their class hierarchy is shown as follows:
76 Self-Instructional Material
InputStream Class Internet Scripting Languages
• FileInputStream class
• ByteArryInputStream class
• StringBufferInputStream class
NOTES
• SequenceInputStream class
• PipedInputStream class
• FilterInputStream class
• BufferedInputStream class
• LineNumberInputStream class
• PushBackInputStream class
• DataInputStream class
Program: A program that demonstrates InputStream class
public class Example
{
static String ss = new String(“Today upon a bus, \n”
+ “ I saw a lovely girl” + “ with golden hair. \n”);
static StringBufferInputStream sbis = new
StringBufferInputStream(ss);
public static void main(String argv[ ])
{
int cc;
try
{
while((CC = sbis.read( ))! = -1)
{
System.out.println((char)cc);
}
catch(Exception e)
{
System.out.println(“Error:” + e.toString( ));
}
}
}
}
Output of the program:
Today upon a bus,
I saw a lovely girl with golden hair.
3.4.2 OutputStream Class
The counterpart to InputStream is the OutputStream class which provides the
basic functionality for all output streams.
• write( ) : Writes data to the stream.
• flush( ) : Forces any buffered output to be written.
• close( ) : Closes the stream.
The Java output stream classes and their class hierarchy is shown as follows:
OutputStream Class
• FileOutputStream class
• ByteArrayOutputStream class
• PipedOutputStream class
• FilterOurputStream class
Self-Instructional Material 77
Internet Scripting Languages • BufferedOutputStream class
• PrintStream class
• DataOutputStream class
Program 5: A program that demonstrates the OutputStream class
NOTES import.io.*;
public class Example1
{
public static void main(String argv[ ])
{
byte buffer[ ] = new byte[64];
try
{
System.in.read(buffer, 0, 64);
}
catch(Exception e)
{
System.out.println(“Error:” + e.toString(
));
}
try
{
FileOutputStream out = new
FileOutputStream(“test.txt”);
out.write(buffer);
}
catch(Exception e)
{
System.out.println(“Error:” + e.toString( ));
}
}
}
Output of the program:
When you run the program, you will get the text cursor blinking.
you type Hello World
The program will create a file whose name is test.txt and content is
Hello World
3.5 APPLETS
An applet, a small Java program, is much more focused in scope than a full-fledged
Java application. What an applet does is up to you—the programmer. An applet is not
Applet: A small Java run from the command line like an application. An applet can be considered as a small
program, is much more
focused in scope than a
pre-compiled Java program that can be run using an applet viewer or a Java enabled
Lfull-fledged Java applicatio browser.
3.5.1 Applets and Web Pages
Web pages are created using HTML files. When the Web browser running on your
system visits a Web page stored on a remote system over the Internet, the corresponding
HTML file is downloaded into your local system. The Web browser then deals with
this HTML file. There are HTML tags that instruct the Web browser to do things.
Applets are embedded in an HTML file. There is an HTML tag <applet> that will
78 Self-Instructional Material
cause your Web browser or applet viewer to download your pre-compiled Java applet Internet Scripting Languages
into your local system and run it.
<title>
A simple applet
</title> NOTES
—————
——————
<applet code = “Example.class” width = “350” height
= “200”>
</applet>
3.5.2 Limitations of Applets
The developers of Java have imposed some restrictions on the functionality of applets.
These restrictions limit the capability of applets. However, these restrictions are required
for security reasons. Applets are downloaded from the Website to your local system.
Applets are not given access to a local machine’s file system. Thus, applet can
neither read a file from the local machine, nor can it save a file on the local system.
In addition to these limitations, there are limitations imposed by the Web browsers.
Web browsers are trusted applications. It does not damage any file or operating system
on the machine it is running. Web browsers limit an applet’s network connectivity.
Applets are allowed network connection only with the Web server from where it is
downloaded. This means that you cannot have your HTML document, applet code,
data and Web browser at four different locations. Your HTML document, applet
code, and the data it uses have to be in one location.
3.5.3 Applet Basics
Applet basically is a Java class defined in the java.applet package of the JDK. Applet
class and its class hierarchy is as follows:
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Panel
java.applet.Applet
The Applet class, which is in the java.awt.applet package, inherits the
properties of the Panel class, which is in java.awt package. The Panel class inherits
the properties of the Container class in the java.awt package. The Container Check Your Progress
class inherits the properties of the Component class, which is again in the java.awt 1. What is JavaScript?
package. All these sub classing has some advantages. Each of these classes implements 2. What is the use of
a variety of methods. All or part of these methods are passed down and made available JavaScript in Web pages?
80 Self-Instructional Material
The HTML file for this is: Internet Scripting Languages
<html>
<applet code= “Example1.class” width=”400" height=”200">
</applet>
</html>
NOTES
When this applet is viewed through the applet viewer, you will get a blank
window of dimensions 400×200 pixels on the screen.
The next applet is an extension of the hello world applet. The display is made
more attractive here. It demonstrates the use of colors and fonts.
Java code for the modified Hello World applet:
import java.awt.*;
import java .applet.*;
public class Example3 extends java.applet.applet
{
static final String message =”Hello world”;
private Font font;
public void init()
{
Font f1 =new font(“Helveltica”,font.BOLD,48);
}
public void paint (Graphics g)
{
g.setColor(Color .pink);
g.fillOval(10,10,330.100);
g.setColor (Color.red);
g.drawOval(10,10,330,100);
g.drawOval(9,9,332,102);
g.drawOval(8,8,334,104);
g.drawOval(7,7,336,106);
g.setColor (Color.black);
g.setFont(font);
g.drawString(message,40,75);
Self-Instructional Material 81
Internet Scripting Languages The HTML file for the above applet
<html>
<applet code=”Example3.class” width=”400" height=”200">
</applet>
</html>
NOTES
Socket is used to establish connection between a client program and a server program.
The protocols used to create sockets for communication of data are TCP/IP and
UDP.
Socket: It is used to
establish connection TCP/IP
between a client program
and a server program Transmission Control Protocol and Internet Protocol TCP/IP consist of a set of rules
for exchanging information between applications, across networks. TCP is a reliable
and connection-oriented service that transmits information in the form of packets. The
TCP/IP sends the packets to their intended destinations after establishing a connection
with the destination and the recipient sends an acknowledgement to the sender on
receiving the packets. The sender retransmits the data, if the acknowledgement is not
received.
UD Protocol
User Datagram Protocol (UDP) works as a datagram service between the clients and
server. Datagram is a unit of information that consists of a frame and frame in turn
consists of a set of bits. UDP provides fast and connectionless transportation of packets.
The UD protocol is not a reliable protocol, as it does not guarantee the delivery of
packets. The data sent through the UD protocol contains the recipient’s address and
transfers the data without establishing a connection between the sender and the recipient.
Acknowledgement is also not received in this case.
Ports and Sockets
A port is a numeric address, which forms a common channel for communication of
data using a particular protocol. A 16-bit number, ranging from 0 to 65535, represents
ports. Each protocol is assigned a specific port number through which a client makes
a request. Various protocols, with their port numbers, are:
• Transmission Control Protocol/ Internet Protocol (TCP/IP) consists of TCP
and UDP that are used to exchange the data over a network. The TCP/IP
reserves the port number 1024.
• File Transfer protocol (FTP) enables the transfer of files efficiently and reliably
between computers. FTP reserves the port number 21.
• Telnet provides an interactive, text-based communication between a client and
server. The telnet protocol reserves the port number 23.
• Finger enables the file transfer for clients using the FTP. The finger protocol
reserves the port number 79.
• Hyper Text Transfer Protocol (HTTP) enables the interaction of clients with the
Internet. The HTTP reserves the port number 80.
82 Self-Instructional Material
Ports are categorized as either well-known or ephemeral. The well-known port, Internet Scripting Languages
also known as privileged port, is created on the server side. The port number of a
well-known port is less than 1024. The ephemeral port, also known as transient or
temporary port, is created on the client side when a client wants to connect to a server.
The ephemeral port is chosen at random and is destroyed when the client application NOTES
terminates. The port number of the ephemeral port is greater than 1023. Java uses
mainly TCP and UDP protocols for making connection requests.
Figure 3.1 shows how the data is passed to an application across the network.
You create network programs in Java using the java.net package. The java.net package
provides the Socket class that creates a client socket and the ServerSocket class that
enables servers to listen for client requests and accept their connections. The code for
implementing socket connection is:
Implementing Socket Connection;
Socket mySocketConnection;
try
{
mySocketConnection = new Socket(“www.banner.com” , 1201);
Self-Instructional Material 83
Internet Scripting Languages }
catch(IOException e)
{
System.out.println(“Exception is:” +e);
NOTES
}
The above code creates the socket object, mySocketConnection, at port number
1201. The code displays an error message, if it is unable to create a socket object.
3.6.1 Using TCP/IP Sockets
TCP/IP sockets transfer the data over the network using the TCP/IP. TCP sockets
establish the connection between the host computers first and then start sending the
data. This connection is terminated automatically, when the data has been sent to the
specified host. Java provides two types of TCP/IP sockets, client and socket.
The client socket is used to connect the client to the server. The client socket is created
when you create an object of the Socket class. The Socket class is a member of the
java.net package. The Socket class provides constructors for creating the client socket.
The various constructors are:
• Socket(String HostName, int PortNumber) creates a client
socket that connects the local socket to the named host at the specified port
number. This type of constructor throws two Java exceptions,
UnKnownHostException and IOException.
• Socket(InetAddress IPAdress, int PortNumber) creates a
client socket using the existing host, which has a specified IP address and port
number. IP address is the object of the InetAddress class that represents
the IP address of the existing host and PortNumber represents its port
number. This type of constructor throws a Java exception IOException.
• Socket() creates an unconnected socket, with the system-default type of
SocketImpl.
• Socket(InetAddress host, int PortNumber, boolean
stream) deprecated. Use DatagramSocket instead for UDP transport.
• Socket(InetAddress address, int PortNumber, InetAddress
localAddr, int localPort) creates a socket and connects it to the
specified remote address on the specified remote port.
• Protected Socket(SocketImpl impl) creates an unconnected Socket
with a user-specified SocketImpl.
• Socket(String host, int PortNumber, boolean stream)
deprecated. Use DatagramSocket instead for UDP transport.
• Socket(String host, int PortNumber, InetAddress
localAddr, int localPort) creates a socket and connects it to the
specified remote host on the specified remote port.
You can examine the status and the input/output stream associated with the
socket using the socket methods.
Table 3.2 describes the various socket methods.
84 Self-Instructional Material
Table 3.2 Socket Methods Internet Scripting Languages
Method Description
getInetAddress() Returns the IP address of the host computer.
getPort() Returns the port number of the host computer.
getLocalPort() Returns the port number of the local host. NOTES
getInputStream() Returns the input stream that is associated with
the socket.
getOutputStream() Returns the output stream that is associated with
the socket.
Close() Closes the socket connection.
The server socket is used for creating a server application, which enables a server to
communicate with the client. The server socket is created using the ServerSocket
class. The ServerSocket class is a member of the java.net package.
• ServerSocket(int PortNumber) creates a server socket for the specified
port number that has a fixed queue length of 50. The queue length determines
how many client connections the system can accept at a time.
• ServerSocket(int PortNumber, int MAXQueue) creates a server
socket for the specified port number with the specified queue length. The
MAXQueue parameter represents the maximum queue length as integer type.
• ServerSocket(int PortNumber, int MAXQueue, InetAddress
LocalAddress) creates a server socket for the specified port number and
the specified local host address. LocalAddress represents the object of the
InetAddress class that specifies the IP address of that local host.
You can examine the status and the input/output stream associated with the server
socket using the server socket methods.
Table 3.3 describes the various server socket methods.
Table 3.3 Server Socket Methods
Method Description
Socket accept() Finds a connection to be made to this
socket and accepts it.
void bind(SocketAddress Binds the ServerSocket to a specific
endpoint) address (IP address and port number).
int getLocalPort() Returns the port on which this socket is
listening
boolean isClosed() Returns the closed state of the
ServerSocket.
void bind(SocketAddress Binds the ServerSocket to a specific
endpoint, int backlog) address (IP address and port number).
ServerSocketChannel Returns the unique ServerSocketChannel
getChannel() object associated with this socket, if any.
InetAddress Returns the local address of this server
getInetAddress() socket.
SocketAddress Returns the address of the endpoint this
getLocalSocketAddress() socket is bound to, or null if it is not
bound yet.
int Gets the value of the SO_RCVBUF
getReceiveBufferSize() option for this ServerSocket, that is the
proposed buffer size that will be used for
Sockets accepted from this ServerSocket
boolean isBound() Returns the binding state of the
ServerSocket.
Self-Instructional Material 85
Internet Scripting Languages Creating a Server Program
The server program creates a server socket that can communicate with the client
socket using TCP/IP. The TCPServer class creates a server socket by using an object
NOTES of the ServerSocket class. The following program code shows how to use the
ServerSocket class to create a server socket:
Creating a Server Socket
import java.net.*;
import java.lang.*;
import java.io.*;
public class TCPServer
{
public static final int PORT = 1050;
public static void main( String args[])
{
ServerSocket server_socket = null;
Socket socket = null;
System.out.println(“ Server is waiting.... “);
try
{
server_socket = new ServerSocket(PORT);
System.out.println(“TCPServer has been started
:”+ server_socket);
try
{
// Creates a socket connection using TCP/IP
socket = server_socket.accept();
System.out.println(“TCPClient has been
connected :”+ socket);
// Receives the message from the TCPclient
system
DataInputStream dstream = new
DataInputStream(socket.getInputStream());
// Sends the message to the TCPclient system
PrintStream pstream = new PrintStream
(socket.getOutputStream());
pstream.println(“Hello! TCPServer here.”);
pstream.close();
socket.close(); // Terminate the connection
}
catch(SocketException se)
{
System.out.println(“Error in server socket
“+ se.getMessage());
}
catch(Exception e)
{
System.out.println(“Error in server
starting”+ e.getMessage()) ;
}
86 Self-Instructional Material
System.out.println(“ Connection from : “ + Internet Scripting Languages
socket.getInetAddress());
}
catch(Exception e)
NOTES
{
System.out.println(“Error in TCPServer “+
e.getMessage()) ;
}
} // End main()method
} // End of TCPServer class
The above code shows how to create a server socket at port number 1050. The
ServerSocket(PORT) creates a server socket of specified port number. The
server socket can communicate with the socket using the methods,
getInputStream() and getOutputStream().
Creating a Client Program
The client program creates a client socket that can communicate with the server socket
using TCP/IP. The TCPClient class creates a client socket using an object of the
Socket class. The following program code shows how to use the Socket class to
create the client socket:
import java.lang.*;
import java.io.*;
import java.net.*;
import java.net.InetAddress;
class TCPClient
{
public static void main(String args[])
{
Socket socket = null;
DataInputStream dstream = null;
PrintStream pstream = null;
System.out.println(“ Client is connecting to
TCPServer....”);
try
{
InetAddress ipadss
=InetAddress.getByName(“java.sun.com”);
socket = new Socket(ipadss,1050);
pstream = new
PrintStream(socket.getOutputStream());
pstream.println(“ Hi! TCPClient here.”);
D a t a In p u t S t re a m i st r e a m = n e w
DataInputStream(socket.getInputStream());
System.out.println(istream.readLine());
}
catch(SocketException se)
Self-Instructional Material 87
Internet Scripting Languages {
System.out.println(“Error in sockets “ + se);
}
catch(IOException ioe)
NOTES
{
System.out.println(“Input/Output Errors “ + ioe);
}
finally
{
try
{
socket.close(); // Closes the socket
}
catch(IOException ioe)
{
System.out.println(“ Socket closing Errors:” +
ioe.getMessage());
}
} // End finally block
} // End the main() method
} // End the TCPClient class
The above code shows how to create a client socket that can communicate
with the server at port number 1050. The client socket communicates with the server
using the methods, getInputStream() and getOutputstream(). You
can run the client and server program after successfully compiling both the programs.
Figure 10.3 shows the output of above program.
Figure 3.4 shows the output of the client and server program.
Using Internet has become common nowadays. We will now understand how the
Internet interprets the Internet address. For instance, the Internet addresses are written
as www.hotmail.com. Let us write one more address as server.institution.domain. It is
significant to note that the address www.hotmail.com is not the actual address. It is
actually a text version of the Internet address, which is basically a binary representation.
Now we compare www.hotmail.com and server.institution.domain. Here, www is the
name of the server owned by the institution (in this case, it is hotmail) and this server is
connected to the Internet and a domain server (com in this case) which maintains a
database of the addresses of different servers using the same domain com. The domain
name has no geographical relevance, and two sites with the same domain name may
exist at two different ends of this world.
The above mentioned case is the simplest one. Now, let us take the case of a
large organization, which may have several other servers for different purposes, such
as Web server, e-mail server, print server, etc. Now, take this example of
www.sun.planet.universe.in. This address is written in five parts separated by three
dots. This address apparently indicates that a group Planets (planet) comes under an
Universe sub domain which is a part of India domain and maintaining one server sun
out of many servers, which is linked to Internet through its Web server. Similarly, an
organization with several departments may create addresses for its sub-domain with
different servers being maintained there.
90 Self-Instructional Material
The Internet is the collection of several independent networks, which are Internet Scripting Languages
interconnected with one another. Each independent network may have several hosts.
Keeping this in mind, you can now think of your address. Your house has a unique
house number, which is not assigned to any other house in your locality. In this case,
your house can be considered as the host, your as the network and your city as the NOTES
domain. You can write your address in Internet addressing notation as
houseno.locality.city. In case you want to acquaint a foreigner with your address, then
you need to add your country name in your address. In this case it will become
houseno.locality.city.country. Now if someone wants to send you a letter or visit your
house, then is required to come to your country first and then to your city. Only after
fulfilling these two obligations, he can reach your locality and then your house by
locating your house number. The same analogy applies in the case of Internet addressing.
A host on the Internet has two significant functions, namely the identification of
the network and identification of the host on the network. Therefore, the address of
the host comprises of two parts namely the network address and the host address.
These two parts together make 32-bit long IP address for a particular host on the
Internet. The IP address is written in four octets each separated by a dot. It may have
a form like 197.23.207.10. Presently, we are using IP address version 4 (IPv4).
However, IP address version 6 (IPv6) has not yet been implemented.
3.7.1 IPv4 Addressing
IPv4 addresses are uniquely used as identifiers, which work at network layer to
identify the source or destination of IP packets. At present, the version of IP, which is
in use, is called IPv4. In this version, every node on the Internet may have one or
IPv4 addresses: Uniquely
more interfaces and we are required to identify each of these devices with a unique
used as identifiers, which
address assigned to each of them. It means that each node is assigned one or more IP work at network layer to
addresses to invoke TCP/IP. These are logical addresses and have 32 bits. identify the source or
destination of IP packets
Technically, IP addresses are expressed using binary notation with 32-bit long
string. In order to recall these strings easily, dotted decimal notations are used, in
which periods or dots separate four decimal numbers from 0 to 255 representing 32
bits. As there are 32 bits, each decimal number contains 8 bits and is referred to as
octet.
For instance, the IPv4 address 11000000101010000000101000011001 is
expressed as 192.168.10.25 in dotted decimal notation. Given below are the steps to
convert an IPv4 address from binary notation to dotted decimal notation:
• Break 32-bit long address into segments of 8-bit blocks: 11000000 10101000
00001010 00011001
• Write the decimal equivalent to each segment: 192 168 10 25
• Separate the blocks with periods: 192.168.10.25
Following representation shows the structure of IP address.
11000000 10101000 00001010 00011001
192 168 10 25
Dotted Decimal Notation
We have seen that IPv4 address is expressed as a 32-bit number in dotted decimal
notation. IP addresses may have fixed part and variable part depending upon the
Self-Instructional Material 91
Internet Scripting Languages allocation of total addresses to an organization. The fixed part of the address may
range from one octet to three octets and the remaining octets will then be available for
the variable part. An IPv4 address is assigned using these parts. All bits in the fixed
octet (s) are set to 1, whereas the variable octet(s) are set to 0 bits. Thereafter, convert
NOTES the result into dotted decimal notation. For instance, you may take an IP address as
192.168.10.25. Now, set all fixed bits to 1 and set all variable bits to 0. This gives
11111111 11111111 00000000 00000000. After converting it into dotted decimal
notation, the result is 255.255.0.0. This dotted decimal notation with fixed and variable
parts is used as an address prefix to 192.168.10.25 and is expressed as 192.168.10.25/
255.255.0.0. This way of expressing the prefix length as a dotted decimal number is
known as network mask or subnet mask notation.
3.7.2 Classification of IPv4 Addresses
Internet standards allow the following addresses:
1. Unicast — It is assigned to a single network interface located on a specific
subnet and it facilitates one-to-one communication. This is unique address is
used globally for the identification of a device on the network. It may be
understood as the house number in a particular locality. It includes a subnet
prefix and a host ID portion.
• Subnet Prefix — The subnet prefix is basically a network identifier or a
network address portion of an IP unicast address. It should be noted that
all nodes on the same physical or logical subnet must use the same subnet
prefix, which eventually becomes unique within the entire TCP/IP network.
• Host ID — The host ID, which is the host address portion of an IP
unicast address, serves to identify a network node to which some devices
are interfaced. It is also regarded as unique within the network segment.
2. Multicast — It is used for one or more network interfaces located on various
subnets. It facilitates one-to-many communication. It delivers single packets
from one source to many destinations. These addresses are a part of Class D
Multicast: It is used for one addressing scheme.
or more network interfaces
located on various subnet 3. Broadcast — It is allocated to all network interfaces located on a subnet and
is used for one-to-everyone communication on a subnet. It delivers packets
from one source to all interfaces on the subnet. Broadcast addresses may be
further classified as network broadcast, subnet broadcast, all subnets directed
broadcast and limited broadcast.
Internet Addresses are further classified into different categories. The number
bits are used for the address prefix of a single subnet and the number of bits are used
for the host ID. Therefore, it allocates the number of networks and the number of
hosts per network. There are five address classes which are given below: -
• Class A — It uses an 8-bit network number whose first bit is always zero as
shown in Table 2.6. It is reserved for IP unicast addresses. This class is used in
case there are myriad hosts on a network. It uses only one octet to define the
prefix length. The number of networks, which can be accommodated, are 28 or
128. However, out of these 128 addresses, 2 are used for administrative
purposes and 126 addresses are available as prefix length. The remaining 3
octets are used for identifying up to 224 or 16,777,214 host IDs.
• Class B — It uses 16 bits for both the network address and the host address.
In this case, the first two bits are always 10. It is reserved for IP unicast addresses.
92 Self-Instructional Material
It uses 2 octets for a particular network while the remaining two octets are Internet Scripting Languages
deployed by the host IDs. They are particularly used for medium to large-sized
networks. The Class B addresses can cater to 16,384 networks with up to
65,534 hosts per network.
• Class C — It is reserved for IP unicast addresses. It is meant for small networks. NOTES
The first 3 octets specify a particular network and the last octet specify the host
IDs. The Class C addresses may be used by up to 2,097,152 networks with up
to 254 hosts per network. Its first three bits are always set to 110.
• Class D — Class D signifies IP multicast addresses.
• Class E — These addresses are reserved for experimental purposes.
Table 3.6 represents IPv4 addresses classifications.
Table 3.6 Classifications of IPv4 Addresses
32 bit address Number of Maximum
Classification Octet 1 Octet 2 Octet 3 Octet 4 possible number of host
networks or nodes
Class A 0bbbbbbb xxxxxxxx xxxxxxxx xxxxxxxx 27 = 128 224 = 6,777,216
Class B 10bbbbbb bbbbbbbb xxxxxxxx xxxxxxxx 214 =16,384 216 = 65,536
Class C 110bbbbb bbbbbbbb bbbbbbbb xxxxxxxx 221=2,097,152 28 = 256
Class D 1110bbbb followed by a 28 bit multicast
address
Class E 1111; reserved
Electronic mail or e-mail is one of the most popular applications of the Internet today.
It refers to the process of transmission of messages in a communication network which
was started by Ray Tomlinson in 1971.
In Web-based e-mail services, the mail resides in the server and is accessed
using the Web browser. The user can access his e-mails after he has logged onto the
server Web site. Messages can be sent and received from a single e-mail address to
another e-mail address or can be broadcasted, that is, the same message can be sent
to many recipients.
The exchange of messages between two terminals or hosts is done by using
the SMTP along with software programs known as Mail Transfer Agents (MTAs).
These e-mails can be stored either on one of the terminals— the client terminal, the
server terminal or at both the places. Post Office Protocol (POP) and Internet
Message Access Protocol (IMAP) are standard protocols that are used to retrieve
messages from the server. The standard mail box formats available are maildir and
mbox. E-mail clients can also use their own proprietary mailbox formats. However,
while using these they must ensure that they have the necessary conversion software.
The various components of an e-mail are as follows:
• User agent.
• Message transfer agent.
• Message access agent.
3.8.1 User Agent
The User Agent (UA) provides the services which are shown in Figure 3.5.
Self-Instructional Material 93
Internet Scripting Languages
Compose Read Reply to
Message Message Message
NOTES
User
Agent
Forward Manage
Message Mailbox
Sender Receiver
SMTP.Sender_ POP3/IMAP4.
server Recipient_server
96 Self-Instructional Material
Most of the search engines are aware of this approach and Google recently Internet Scripting Languages
started the pre-empting task followed by user that suggests the combination of keyword
for fetching the best result. The basic fundamental concept works with search engine is
that how best to divine the user’s intent and provide the exact result what user is
searching for. Google search is based on the mechanism of algorithm. No matter, it is NOTES
complex mathematical formula that crawls via unlimited Web sites. These sites are on
the net and shown by the ranks according to pages (relevant and well informed
information). Thereby, index is created to top and deliver the search results. Google
search engine blends listings from the news, well-informed documents, and images,
local book search engines that deliver the exact and comprehensive results. Bing, the
Microsoft’s search portal, was launched in year 2009. It works as the ‘decision engine’.
Popular search engines contend with the rapid increasing verticalization of the
Web especially in the field of tour-travel focuses and delvers the best possible results.
The effects are visible in Search Engine Optimization or SEO. In this, the mechanism
is used with the help of Web masters to ensure the Web sites get higher ranking in the
searching the information. Sometimes, Web masters use spam their code with keywords
that impacts on getting recognition from the algorithm of social engines is becoming
smarter and complex so that it can integrate with the artificial intelligence. The searching
domain is getting more user oriented too and will be continuing as it is being believed
by Microsoft. A Web search engine is designed to search for information on the WWW
and FTP servers. The search results are generally presented in a list of results often
referred to as Search Engine Results Pages or SERPS. The information may consist of
Web pages, images, information and other types of files. Search engines are the
Softwares that enable searching of the content available on the Internet. A search
engine is an information retrieval system which is used to access and retrieve information
stored in WWW or a computer system attached to the Internet. Search engines also
help minimize the time required to find the relevant information on the computer system.
The computer system could be a standalone system or it could also be attached to the
Internet. The search engines are popular amongst people as Web search engines help
explores information on the World Wide Web.
Search engines are the interface to a group of contents, which allow the users to
type in the keywords, so that the engine can find several matching contents to the
corresponding keywords out of millions of Web pages. The keywords provided by
the user are referred to as a search query. Several styles of search query syntax are
used by the net users. Search query differs for different types of search engines, that is,
some search engines enable users to enter two or three words separated by space,
whereas others may require users to provide entire documents, pictures, sounds, and
various forms of languages. Some search engines attempt to enhance the search queries
to provide a quality set of items through a process known as query expansion.
http://en.wikipedia.org/wiki/Image:Search-engine-diagramen.svg
Protocol handler is a feature of the Windows Search engine that is used to
communicate with and enumerate the contents of stores, such as the file system,
Messaging Application Program Interface (MAPI) e-mail database, and the CSC or
offline files database. Like IFilters, protocol handlers are also extensible. The protocol Check Your Progress
handler mechanism is an API that enables programmers to add arbitrary URL schemas 10. How are Web pages created?
to the existing set of command URLs by writing additional protocol handlers for them. 11. State a limitation of applet.
A content handler defines what happens with a content part in response to specific events, 12. Define TCP/IP.
such as when the part is activated. The content handler enables you to perform actions 13. Why do we use a server
at particular moments in the lifecycle of the content item. It also enables you to set up socket?
data repositories and manipulate the data model prior to rendering the content item.
Self-Instructional Material 97
Internet Scripting Languages
3.10 REMOTE METHOD INVOCATION
Interface Implementation
RMI
System
Short-Answer Questions
NOTES
1. What is a JavaScript?
2. State the difference between Java and JavaScript.
3. Define the term VBScript.
4. What is URL encoding?
5. What is an InputStream class?
6. How are Web pages created?
7. State the limitations of applets.
8. What is UD protocol?
9. What is the code for implementing socket connection?
10. What is an electronic mail?
Long-Answer Questions
1. Are Java and JavaScript the same? Explain with the help of example.
2. Describe how JavaScript work.
3. Describe VBScript in HTML with the help of an example.
4. Discuss the VBScript data types.
5. What is an OutputStream class? Explain with the help of an example
code.
6. What are the server-side scripting languages? Describe features of each.
7. Describe the applet class and the methods implemented in the applet class.
8. Explain the various constructors needed for creating the client socket.
9. How do you create a client program? Explain the code snippet.
10. What is IPv4 addressing? Classify them.
11. Write a note on subnetting for IP addresses.
12. What is user agent? Explain the various services provided by the UA.
13. Describe the various RMI architecture layers.
4.0 INTRODUCTION
In this unit, you will learn about the Internet markup languages, such as SGML and
HTML. SGML is an ISO standard technology for generalized markup languages for
documents. HTML, XHTML and XML are the examples of SGML based languages.
HTML is a markup language which sets markup tags to describe Web pages. HTML
markup tags are usually known as HTML tags which are keywords surrounded by
angle brackets like <html>. HTML tags appear in pairs like <b> and </b> where
the first tag in a pair is the start tag and the second tag is the end tag. The starting and
ending tags are also called opening tags and closing tags. HTML elements can have
attributes which provide additional information about an element. You will also learn
about anchors. When you click on a link in an HTML page, an underlying <a> tag
Self-Instructional Material 105
Internet Markup Languages points to an address on the WWW. The HTML tables are defined with the <table>
tag. A table is divided into rows with the <tr> tag and each row is divided into data
cells with the <td> tag for table data which holds the content of a data cell. A <td>
tag can contain text, links, images, lists, forms, other tables, etc. Finally, you will learn
NOTES about forms and frames. A form can contain input elements like text fields, checkboxes
and radio buttons, submit buttons and more. With frames, you can display more than
one HTML document in the same browser window. The <frame> tag defines one
particular window (frame) within a frameset. Each HTML document is known as a
frame and each frame is independent of the others. Each frame element can hold a
separate document. You will also learn about the significance of XHTML and DHTML.
Internet Explorer is a series of graphical Web browsers, developed by Microsoft and
included as a part of the Microsoft Windows operating systems. You will learn about
the anatomy of Internet Explorer. Finally, you will learn about the netscape expensions,
shockware and lingo.
In 1980, Tim Berners Lee, a physicist, now the Director of W3C (World Wide Web
Consortium), designed a system to use and share documents. In 1989, Tim proposed
a hypertext system based on the Internet and by end of 1991, wrote the first
specifications for HyperText Markup Language or HTML which contained 20 elements.
HTML: A language that
Thirteen of these elements still exist in HTML 4. HTML specifications are maintained
provides a very simple by the W3C. The last HTML specification published by W3C was HTML 4.01.
mechanism to format a Web
page, outputting page in
Advantages of HTML
different formats, designing HTML is a language that provides a very simple mechanism to format a Web page,
tables, embedding images outputting page in different formats, designing tables, embedding images and other
and other objects
objects. One can play with text according to its own requirement. Secondly, it is very
106 Self-Instructional Material
easy to learn and is the most widely accepted language for Web designing. One need Internet Markup Languages
not be an expert to write HTML documents.
HTML and World Wide Web
The terms World Wide Web or WWW and Internet are used in everyday speech NOTES
without any distinction. The Internet is a global system of computer systems
interconnected to each other. Web is a service which runs on the Internet. WWW is a
system of linked HTML documents over the Internet. This collection of information is
linked by hypertext links and is known as a Web of information, that is available on the WWW: A system of linked
Internet and thus creates the WWW. A Web browser is used to view these pages on HTML documents over the
the Internet. HTML is the most widely accepted language of the Web. HTML is the Internet
language used for publishing on WWW. World Wide Web is primarily composed of
HTML documents, which are transferred from the Web server to the Web Browser
using the HTTP or HyperText Transfer Protocol. All Internet browsers follow HTML
standards to view an HTML page. Extraction tools like Python follow HTML standards
to extract information from Web pages.
Internet Protocols
HTTP is the application protocol which is used over the WWW to transfer HTML
pages between your application (typically a Web browser) and the Web server publishing
the HTML page. The standards for HTTP were developed by the W3C and IETF
(Internet Engineering Task Force). The version of HTTP available in common use is
HTTP/1.1.
HTTP is the standard for request/response based typical client-server computing.
A client is an application (a Web browser) and the server is the computer hosting the
Web page. The client/application which submits an HTTP request to a server is referred
as an User Agent. The Web Server which stores HTML files and resources is known HTTP: The standard for
as an Origin Server. HTTP uses Transmission Control Protocol/Internet Protocol or request/response based
typical client-server
TCP/IP for reliable transport. The transfer of Web pages from server to client over computing
HTTP is done on TCP/IP layer. HTTP is not constrained to use TCP/IP, it can use any
Internet protocol that provides reliable transport. A Web server runs on an IP address
and you can contact that Web server using the HTTP protocol and request a Web
Page. A Web server then checks whether it hosts that page or not, if it does then it
returns that page over HTTP and your browser displays the page.
Devices Used over the Internet
Internet basically stands for Internetwork. On the Internet, different networks are
interconnected via various Internet devices like routers, gateways, proxies, tunnels,
etc. Routers and gateways are devices which connect two networks and do the job of
routing a message from one network to another network. Proxies are servers which Proxies: Servers which act
act as a proxy for you over the network and hide the network behind it. For HTTP as a proxy for you over the
protocol, this matrix is unknown as it relies on TCP/IP for the connection between two network and hide the
machines in different networks. HTTP can work over any protocol that provides a network behind it
reliable transport. Discussing the Internet matrix is beyond the scope of this book.
Delivery Mechanism of HTML Document on World Wide Web
The HTML documents are delivered from a Web server to a client via the HTTP
protocol running over TCP/IP. This HTTP transfer takes place in the following way:
• A Uniform Resource Locator or URL is typed in to the browser.
Self-Instructional Material 107
Internet Markup Languages • Server name portion from the URL is extracted and resolved into an IP Address
using a global Internet database called the Domain Name System or DNS.
• This IP address is required to make a connection to the server over the TCP/IP
layer. A transport connection is made to the server over the TCP/IP layer.
NOTES
• A browser then requests the resource mentioned in the URL from the Web
server over the HTTP protocol.
• If the resource is found, the server sends an OK response which then returns
the HTML over the HTTP, otherwise it returns a 404 response.
File Naming Conventions in HTML
All HTML file use .html or .htm as file name extension. This extension uniquely identifies
an HTML file and associates them directly to the Web browser.
Standard Generalized Markup Language
The Standard Generalized Markup Language (ISO 8879:1986 SGML) is an
ISO (International Organization for Standards) standard technology for defining
generalized markup languages for documents.
Generalized markup is based on the following two novel postulates:
1. Markup should be declarative. It should describe a document’s structure
and other attributes, rather than specify the processing to be performed
on it. Declarative markup is less likely to conflict with unforeseen future
processing needs and techniques.
2. Markup should be rigorous so that the techniques available for processing
rigorously-defined objects like programs and databases can be used for
processing documents as well.
HTML, XHTML and XML are all examples of SGML-based languages.
An SGML document may have three parts:
1. The SGML declaration.
2. The Prologue, containing a DOCTYPE declaration with the
various markup declarations that together make a Document Type
Definition (DTD).
3. The instance itself, containing one top-most element and its contents.
An SGML document may be composed from many entities (discrete pieces of
text). In SGML, the entities and element types used in the document may be specified
with a DTD, the different character sets, features, delimiter sets and keywords are
specified in the SGML declaration to create the concrete syntax of the document.
Although full SGML allows implicit markup and some other kinds of tags, the
XML specification states the following features:
• Each XML document has both a logical and a physical structure.
• Physically, the document is composed of units called entities. An entity
may refer to other entities to cause their inclusion in the document.
• A document begins in a ‘root’ or document entity. Logically, the document
is composed of declarations, elements, comments, character references
108 Self-Instructional Material
and processing instructions all of which are indicated in the document by Internet Markup Languages
explicit markup.
Optional Features
SGML generalizes and supports a wide range of markup languages as found in the NOTES
mid 1980s. These ranged from terse wiki-like syntaxes to RTE-like bracketed languages
to HTML-like matching-tag languages. SGML did this by a relatively simple
default reference concrete syntax augmented with a large number of optional features
that could be enabled in the SGML Declaration. Not every SGML parser can necessarily
process every SGML document. Because each processor’s System Declaration can
be compared to the document’s SGML Declaration it is always possible to know
whether a document is supported by a particular processor.
Many SGML features relate to markup minimization. Other features relate to
parallel asynchronous markup (CONCUR), to linking processing attributes (LINK)
and to embedding SGML documents within SGML documents (SUBDOC).
The notion of customizable features was not appropriate for Web use, so one
goal of XML was to minimize optional features. However XML’s well-formed rules
cannot support Wiki-like languages, leaving them un-standardized and difficult to
integrate with non-text information systems. Actually, SGML is used to define a markup
language. An example of an HTML document (one of the markup languages) follows:
<!DOCTYPE HTML”/strict.dtd”>
<HTML>
<HEAD>
<TITLE>My first HTML document</TITLE>
</HEAD>
<BODY>
<P>Hello world!
</BODY>
</HTML>
The preceding HTML document is divided into a header (here, between
<HEAD> and </HEAD>) and a body (here, between <BODY> and </BODY>).
The title of the document is in the header, besides other information about the document.
The content of the document is in the body. There is just one paragraph in it, markup
with <P>.
Theoretically, every SGML document has both a logical and a physical structure.
Logically, a document is made up of elements, declarations, attributes, character
references, comments, and so on. All these are shown in the document by clear markup.
Physically, the document is made up of units known as entities. A document
starts in a document entity. SGML is not only used for conventional document markup,
but it can be used for marking up any type of text. Header, paragraphs, footnotes,
sections, hypertext links, tables, images, etc., are the elements in a SGML text. Every
element usually describes the following three parts:
(i) A start tag.
(ii) Content.
(iii) An end tag.
Self-Instructional Material 109
Internet Markup Languages The name of the element appears in the start tag (written <element-name>)
and the end tag (written </element-name>). Elements may have related properties
called attributes. The latter may have values (by default or set by authors or scripts).
Attribute/value pairs show before the final “>” of an element’s start tag. In the start tag
NOTES of an element numerous (legal) attribute value pairs, separated by spaces, may become
visible. They can appear in any order. Numeric or symbolic names included in an
SGML document are called character reference. These character references help in
referring to rarely used characters or those that authoring tools make it difficult or
impossible to enter. They begin with a ‘&’ sign and end with a semi-colon (;). Following
are examples of character references are:
‘<’ correspond to the < sign.
‘>’ correspond to the > sign.
‘"’ correspond to the ’ mark.
‘å’ (in decimal) correspond to the letter ‘a’ with a small circle above it.
‘И’ (in decimal) correspond to the Cyrillic capital letter ‘I’.
SGML comments have the following syntax:
<!— this is a comment —>
<!— and so is this one,
which occupies more than one line —>
Between the markup declaration open delimiter (‘<!’) and the comment open
delimiter (‘—’), white space is not allowed. However, it is allowed between the comment
close delimiter (‘—’) and the markup declaration close delimiter (‘>’). To include a
series of hyphens (‘—’) within a comment is a common error. Any information that
shows between remarks has no particular meaning.
In any markup norm the angle brackets are used as start and end tag delimiters.
However, in an SGML text, it is permissible to use other characters, provided an
appropriate tangible syntax is defined in the text of the SGML declaration. For instance,
an SGML interpreter may be programmed to parse GML markup, wherein the tags
are delimited with a left colon and a right full stop, thus, an :e prefix indicates an end
tag: :xmp.Hello, world:exmp.
As per the reference syntax, upper or lower case is not important in tag names,
thus the three tags: (i) <quote>, (ii) <QUOTE> and (iii) <quOtE> are similar.
In SGML, tags could be substituted with delimiter strings, for example two
equals signs (==) at the beginning of a line are the ‘heading start tag’ and two equals
signs (==) after that are the ‘heading end-tag’. One characteristic of SGML is the
presumpt uous empty tagging, such t hat t he empty end tag < / > in
<ITALICS>this</> takes its value from the closest preceding full start tag,
which in this example is <ITALICS>. Thus, it closes the most recently opened item.
The appearance is hence equal to <ITALICS>this</ITALICS>. SGML also
permits implied markup, various types of tags and many other not obligatory features.
Every SGML parser does not automatically process every SGML text. However,
as the system declaration of the processor can be contrasted to the SGML declaration
of the text, it was for all time likely to understand if a text was supported by a particular
processor or not. Parsing a SGML document that involves traversing the dynamically
110 Self-Instructional Material
retrieved entity graph, finding or imply tags and the element structure, and validating Internet Markup Languages
those tags against the grammar.
The SGML equivalent is known as Document Type Definition (DTD). It defines
only the structure; DTD describes all the texts of a particular type, in terms of the tags
NOTES
that may be used to mark them. SGML without a DTD (for example, simple XML) is
a grammar or a language; SGML with a DTD is a Meta language. A separate
specification of style layout complementing the DTD is called style sheet. For each tag
defined in the DTD, a style sheet provides a rule describing the way in which elements
with the tag should be laid out. There may be more than one style sheet for a DTD,
providing different appearance to the same structure. Since HTML tags were not
enough for the class of Web pages developed over time there was a requirement from
the Web designers to be able to define their own tags. Though SGML has that facility,
it is not completely appropriate for use over the Internet. Work on making SGML
compatible to the Internet led to the development of eXtensible Markup Language
(XML) that gives all the facilities of SGML without the overhead (for complicated
parsing) forced by SGML. In fact, XML permits Web designers to define their own
DTDs for any type of document and Web pages are freed from the limitations of
HTML’s definition of a document.
4.2.1 HTML Tags
HTML pages are written in the form of HTML elements. HTML elements can be
described as tags surrounded by angle ‘brackets ‘<’ and ‘>’, which are interpreted
by the browser to perform a specific formatting. Following is an example of how the
basic HTML tags are used.
In HTML, every tag has a corresponding closing tag. A Web browser interprets
these tags and then renders the display on the screen depending upon the tag and its
attributes. Following are the features of an HTML file:
• The text between <html> and </html> describes the Web page.
• HEAD contains metadata information for HTML file.
• The text between <body> and </body> is the visible page content.
• All HTML tags should be properly ended by their corresponding closing tags
otherwise it can interfere with the display and may not be as expected.
• All HTML tags are case insensitive.
Creating an HTML Document
Try the following HTML in your browser:
<html>
<head>
<title>First Page</title>
</head>
<body>
My name is <b>Albert Einstien</b>. This
is my first <u>HTML</u> page.
</body>
</html>
NOTES
In the above example, the content between the <body> tag is rendered on
screen by browser. The text Albert Einstien surrounded by tag <b> tells the browser
to display this text as bold. Similarly, the text HTML surrounded by tag <u> is displayed
as underlined. The text First Page in the title tag, in the head section tells the browser
to display it as the window title.
Essential Tags
Essential HTML tags are discussed below:
• The <html> Tag: The <html> tag is supported by all major browsers.
This tag tells the browser that this is an HTML document. The <html>
element is also known as the root element. The <html> tag is the container
for all other HTML elements except for the <!DOCTYPE> tag.
• HTML <body> Tag: All text within the HTML document body will be
displayed by the Web browser for the user to see. Therefore it is important to
keep the body tags <body> and </body> around all of the content you
want your visitors to see.
Deprecated Tags
Older HTML tags and attributes that have been superseded by other more functional
or flexible alternatives whether as HTML or as Cascading Style Sheets or CSS
are declared as deprecated in HTML 4 by the W3C that sets the HTML standards.
Table 4.1 summarizes the list of Deprecated HTML tags.
Check Your Progress Table 4.1 Deprecated HTML Tags
1. What is origin server? Deprecated Description Replacement
2. What are proxies? <applet> Inserts applet <object>
<basefont> Sets font styles Font style sheets
3. How HTML documents are <center> Centres elements <div style=“text-
delivered? align:center”>
4. Name the file name <dir> Directory list <ul>
extensions which are used in <font> Applies font styles Font style sheets
HTML file? <isindex> Adds search field <form>
5. How HTML elements can <menu> Menu list <ul>
be described? <s> Strikethrough Text style sheets
<strike> Strikethrough Text style sheets
6. Write the function of
<u> Underline Text style sheets
<head> and <body> parts
of an HTML file.
7. Which element is known as
root element? 4.3 TAGS AND ATTRIBUTES
8. Which deprecated tag is
used as <object> HTML elements are tags and are enclosed within angle brackets ‘<’ and ‘>’, which
replacement to insert act as indicators to a Web browser as to how the document is to be interpreted by the
applets in HTML?
browser and ultimately presented on the user’s computer screen. For example,
112 Self-Instructional Material
‘<b>Albert Einstien</b>’ is an HTML element which tells the browser to Internet Markup Languages
display the text placed between the shorting and closing tag as bold. Even the plain
text is an HTML element. Elements may represent links, paragraphs, headings or
some embedded objects like audio or video. HTML elements may contain other
elements which may be empty. Empty elements consist of only a single tag, with or NOTES
without any attributes, appended by the forward slash ‘/’.
Following are the few basic characteristics of HTML tags:
• An HTML element starts with a start tag/opening tag.
• An HTML element ends with an end tag/closing tag.
• The element content refers to everything between the start and the end tag.
• Some HTML elements have empty content.
• Empty elements are closed in the start tag, for example, <br/> and <hr/
> are empty elements closed in a single tag.
• Most HTML elements can have attributes.
All HTML elements are SGML (Standard Generalized Markup Language)
elements which meet the specifications of various HTML Document Type Definition
or DTDs’. HTML elements are defined by many open standards, initially by IETF
(Internet Engineering Task Force) and now by W3C.
Primary function of HTML is to add semantic information and structural view to
the raw text of the document.
Notes: (i) An HTML element should always have its closing tag, otherwise formatting on screen
could be different from what expected.
(ii) HTML tags are not case sensitive. The World Wide Web Consortium or W3C recommends
lowercase in HTML 4 and demands lowercase tags in the future versions of XHTML.
HTML Source
The content written between the <html> tags is known as an HTML source and is
interpreted by the browser to render the display. You can go to the browser window
and right click the mouse. It will pop-up a menu. There will be a menu item ‘View
Source’, select this option. A text editor window will open showing the content of
HTML file which you opened in browser.
HTML Tags and Arrangement
In HTML, only one rule follow, ‘every opening tag should have a closing tag’. If
tags are not closed properly, then the display on your browser screen could be
different from what is expected.
In general practice, use some indentation for every child element with respect to
its parent element. Use a new line with proper indentation whenever you start a new
element. It keeps the source viewable, and easy to read and understand.
Rule for Whitespace
In HTML, extra white spaces and new lines are neglected. Any number of lines or
spaces is count as one space. Try the following HTML in your browser:
<html>
<head>
<title>First
Page</title>
Self-Instructional Material 113
Internet Markup Languages </head>
<body>
Hi everybody,this is an example of nesting of HTML
elements.
NOTES <b>This a text line in bold with parts in
<i>Italic text</i> and
<u>Underlined Text</u></b>.
</body>
</html>
To add extra space, a special whitespace character is used in HTML
and to add a new line, the <br/> tag is used.
Comments for Better Understanding
One can also insert comments into the HTML file and these comments will not display
on the browser. HTML comments are written in between <!— and —> tags. Try the
following HTML below in your browser:
<html>
<head>
<title>First Page</title>
</head>
<body>
<!— This is a HTML Comment and will not be
displayed on the screen —>
Hi everybody, this is an example of
nesting of HTML elements. <b>This a text
line in bold with parts in <i>Italic
text</i> and <u>Underlined Text</u></
b>.
</body>
</html>
You will not see the commented line on the browser. It is neglected by the
browser. You can verify it by viewing the source of the displayed HTML. Right-click
mouse in the browser window and select ‘View Source’ from the pop-up menu.
Special Characters
In HTML, few characters have a special meaning like ‘<’ , ‘>’, ‘&’, etc. Angle brackets
represents the start or end of an HTML tag. Ampersand (&) represents the start of
special characters. To render their display on the screen, HTML uses special characters
to represent them.
Table 4.2 shows a list of few commonly used HTML special characters.
link
Attribute link is an attribute of the <body> tag. The link attribute specifies the
default color of unvisited links in a document. The value of this attribute is a color value
specified either by its standard name or by its RGB value. Color value could be a
color name likes red, blue, green, yellow, etc., or any standard color name. It could be
an RGB value specified in hexadecimal number format like green value is 00ff00,
red is ff00000 and blue is 00000ff.
alink
Attribute alink is an attribute of the <body> tag. The value of this attribute is a
color value specified either by its standard name or by its RGB value. It renders all the
links present in the Web page of the specified color value. Color value could be a
color name like red, blue, green, yellow, magenta, etc., or any standard color name. It
could be an Red Green Blue or RGB value as specified in a hexadecimal number
format like green value is 00ff00, red is ff0000 and blue is 0000ff.
vlink
The attribute vlink is an attribute of the <body> tag. The value of this attribute is
a color value as specified either by its standard name or by its RGB value. It renders
all the visited links present in the Web page of the specified color value. Color value
could be a color name like red, blue, green, yellow, magenta, etc., any standard color
name. It could be an RGB value specified in hexadecimal number format like green
value is 00ff00, red is ff0000 and blue is 0000ff.
116 Self-Instructional Material
4.3.2 <font> Element Internet Markup Languages
The <font> tag specifies the face, color and size of the text written in this tag. The
element <font> is used to format the text into the desired font size and color. Try
the following HTML in your browser: NOTES
<html>
<head>
<title>Font Example</title>
</head>
<body>
Hi everybody, this is an example of Font element. You can
see the fonts in different colors like <font color=’0x00ff00"
face=’Courier’>GREEN</font> and <font color=’0x0000ff’
face=’Calibri’>BLUE</font> and in different font sizes like
<font size=’1">SMALL</font> or <font size=’4">MEDIUM</font>
and <font size=’6">LARGE</font>.And Also in different faces
like <font face=’Calibri’>Calibri</font> and <font
face=’Courier’>Courier</font> and <font face=’Arial’>Arial</
font>.
</body>
</html>
The output on the screen will be display as follows:
Attributes associated with the <font> tag have been described in Table 4.4.
Table 4.4 Attributes of the <font> Tag
Attribute Value Description
color rgb(x,x,x) Specifies the color of text.
#xxxxxx
colour name
face font_family Specifies the font of text.
size number Specifies the size of text.
class classname Specifies a classname for an element.
dir rtl Specifies the text direction for the content in an element.
ltr
id Id Specifies a unique id for an element.
lang language_code Specifies a language code for the content in an element.
style style_definition Specifies an inline style for an element.
title Text Specifies extra information about an element.
color Attribute
In the above example, the color attribute specified in the <font> tag renders the
text in that color. Color value could be a color name like red, blue, green, yellow,
magenta, etc., or any standard color name. It could be an RGB value specified in
Self-Instructional Material 117
Internet Markup Languages hexadecimal number format like green value is 00ff00, red is ff0000 and blue is
0000ff. Try the following HTML in your browser:
<html>
<head>
NOTES
<title>Font Example</title>
</head>
<body>
Hi everybody, this is an example of Font element. Different
colors can be used in font Element like:
<br/> <font color=’00ff00" >GREEN</font>
<br/><font color=’0000ff’ >BLUE</font>
<br/><font color=’ff0000" >RED</font>
<br/><font color=’ffff00" >YELLOW</font>
<br/><font color=’00ffff’ >LIGHT BLUE</font>
<br/><font color=’ff00ff’ >MAGENTA</font>
</body>
</html>
face Attribute
The face attribute specified in the <font> tag renders the text in that font face.
The face value is the name of the font like courier, calibri, arial, etc.
The font used for text formatting needed to be installed on the client machine otherwise
the browser will not be able render the text in that font and will use the browser default
font instead. Try the following HTML in you browser:
<html>
<head>
<title>Font Example</title>
</head>
<body>
Hi everybody, this is an example of Font element. Different
face can be used in font Element like:
<br/> <font face=’arial’ >ARIAL</font>
<br/><font face=’courier’ >COURIER</font>
<br/><font face=’comic sans ms’ >COMIC SANS MS</font>
<br/><font face=’times new roman’ >TIMES NEW ROMAN</font>
<br/> <font face=’verdana’ >VERDANA</font>
<br/> <font face=’helvetica’ >HELVETICA</font>
size Attribute
The size attribute specified in the <font> tag renders the text in that particular
font size. The size value is an integer number that specifies the font size in pixel
point. Try the following HTML in your browser:
<html>
<head>
<title>Font Example</title>
</head>
<body>
Hi everybody, this is an example of Font element. Different
size can be used in font Element like:
<br/> <font size=’1" >TEXT</font>
<br/> <font size=’2" >TEXT</font>
<br/> <font size=’3" >TEXT</font>
<br/> <font size=’4" >TEXT</font>
<br/> <font size=’5" >TEXT</font>
<br/> <font size=’6" >TEXT</font>
</body>
</html>
The output on the screen will be displayed as follows:
Text is also an HTML element. Text formatting is the major crux of HTML. Any text
other than tags and attributes, which is present in the <body> tag of HTML file will
be displayed on the screen. Later on in this book, you will learn various HTML tags
for formatting text and effects.
Self-Instructional Material 119
Internet Markup Languages Some other text formatting tags are as follows in Table 4.5.
Table 4.5 Text Formatting Tags
Tag Description
Striking Text
The tags <s> and <strike> are used to strike through the text. Try the following
HTML in your browser:
<html>
<head>
<title>Pre formatted text Example</title>
</head>
<body>
This is an example of <s>stike through text</s> using
element s. <br/>
This is an example of <strike>stike through text</strike>
using element strike. <br/>
</body>
</html>
Text Properties
These properties are used to set the behaviour of the text on the screen. Table 4.7 lists
the text properties as follows:
Table 4.7 Text Properties
Property Description
color Sets the color of text.
direction Specifies the text direction/writing direction.
letter-spacing Increases or decreases the space between characters in a text.
line-height Sets the line height.
text-align Specifies the horizontal alignment of text.
text-decoration Specifies the decoration to be added to the text.
text-indent Specifies the indentation of the first line in a text block.
text-shadow Specifies the shadow effect added to text.
text-transform Controls the capitalization of text.
vertical-align Sets the vertical alignment of an element.
white-space Specifies how the white space inside an element is handled.
word-spacing Increases or decreases the space between words in a text.
Background Properties
These properties when specified in the element, change the background of the element.
These properties can be a background image or background color, etc. Table 4.8
shows a list of these properties as follows:
Property Description
Background- Sets whether a background image is to be fixed or scrolled with the rest of NOTES
attachment the page.
In HTML, you can define a definition list. A definition list is a list of elements
with their respective definitions. Tags which are used in defining a definition list are as
follows:
• <dl>: Defines a definition list.
• <dt>: Defines an item in definition list.
• <dd>:Describes the item in the list.
Try the following HTML in your browser:
<html>
<head>
<title>List Formatting Examples</title>
Self-Instructional Material 123
Internet Markup Languages </head>
<body>
<h3>Ordered List</h3>
<ol>
NOTES <li>Orange</li>
<li>Mango</li>
<li>Apple</li>
</ol>
<hr/>
<h3>Unordered List</h3>
<ul>
<li>Tea</li>
<li>Coffee</li>
<li>Milk</li>
</ul>
<hr/>
<menu>
<li>HTML</li>
<li>DHTML</li>
<li>CSS</li>
</menu>
<hr/>
<dir>
<li>HTML</li>
<li>DHTML</li>
<li>CSS</li>
</dir>
</body>
</html>
The output on the screen will be displayed as follows:
In HTML, images are defined with the <img> tag. Basically, the <img> tag is empty,
which means that it contains attributes only and has no closing tag. To display an image NOTES
on a page, you need to use the src attribute, where src stands for ‘source’. The height
and width attributes are used to specify the height and width of an image. Hence, both
the height and width attributes for an image must be specified. If these attributes are set,
the space required for the image is reserved when the page is loaded. In these attributes
are not defined then the browser does not know the size of the image. The effect will
be that the page layout will change while the images load. When a Web page is loaded,
it is the browser that gets the image from a Web server and inserts it into the page.
Therefore, the images must be stored at specified link location otherwise you will get
a broken link icon. The broken link icon is shown if the browser cannot find the image.
4.6.1 Tag for Images
Images used in HTML documents are classified into the following two classes:
1. Inline images.
2. External images.
Inline images are seen on a Web page with the text and links. They are loaded
automatically when an HTML document is viewed on the Web browser. External images
cannot be displayed directly. They are stored isolated from the HTML document and
are loaded only when asked for Graphical Interchange Format (GIF) and Joint
Photographic Experts Group (JPEG) are the generally used formats for images.
Using the <img> Tag
The <img> tag can be used to display the inline images. The following program shows
the syntax to implement the <img> tag:
<img
src=”location”
height=”height”
width=”width”
name=”imageName”
alt=”alterntiveText”
align=”alignment”
border=”borderWidth”
hspace=”horizMargin”
vspace=”verticalMargin”
usemap=”#mapName”
>
In the preceding program, the various attributes of the <img> tag are as follows:
• src: It specifies the location of the image that needs to be inserted into an
HTML document.
• height: It specifies the height of the image either in pixels or percentage
height with respect to the Web browser window.
• width: It specifies the width of the image either in pixels or percentage width
with respect to the Web browser window.
Self-Instructional Material 125
Internet Markup Languages • name: It refers to the name for the image.
• alt: It specifies the text to be displayed when the Web browser does not support
the <img> tag.
• align: It specifies the image alignment in reference to the surrounding text.
NOTES The values that can be assigned to this attribute are as follows:
ο right: It is used to align an image according to the right margin.
ο left: It is used to align an image according to the left margin.
ο top: It is used to align an image according to the top margin of the current
line.
ο absmiddle: It is used to align the centre an image according to the
middle of the current line.
ο absbottom: It is used to align the middle of an image according to the
bottom of the current line.
ο texttop: It is used to align the top of an image according to the top of
the current line.
ο middle: It is used to align the middle of the image according to the text
baseline of the current line.
ο baseline: It is used to align the bottom of an image according to the
text baseline of the current line.
ο bottom: It is used to align the image in the same way as the BASELINE
attribute. This is the default value of the align attribute.
• border: It specifies thickness of the border of an image, in pixels.
• hspace: It specifies the margin in pixels between the surrounding text and the
right and left edges of the image.
• vspace: It specifies the margin in pixels between the surrounding text and the
top and bottom edges of the image.
• usemap: It represents an image map and specifies which MAP tag is used to
define the mapping for this image.
The following code shows how to use the <img> tag:
<img src=”image1.jpg” height=300 width=200 border=”2">
In the preceding program, the <img> tag is utilized to insert image1.jpg in an
HTML document. The width of the image is specified as 200 and the height is specified
as 300. The thickness of the border is specified as 2 pixels.
You can also wrap an image with text around it. The following code shows how
to insert an image that is surrounded by text:
<p>
<img src=”fig.jpg” hspace=40 border=2 align=LEFT >
This text will appear with the image.
</p>
In the preceding program, the <p> tag displays both image and text. The <img>
tag can be used to insert a left-aligned image. The text, ‘This text will appear
with the image’, will be displayed to the right side of the image with a margin of
40 pixels.
Images can also work as hyperlinks. You have to use the <img> tag inside the opening
and closing part of the anchor tag. The following code depicts shows how to use an
image as a hyperlink:
<a href=”index.html”> NOTES
<img src=”fig.jpg”>
</a>
In the preceding code, the <img> tag is nested inside the anchor tag. The image
works as the hyperlink that links the page, index.html. The Web browser shows the
HTML document, index.html when you click on the image, fig.jpg.
Text and image can be used together to display a hyperlink. The following code
shows how to use text and image together to represent a hyperlink:
<html>
<head>
</head>
<body>
<a href=”index.html”><IMG src=”button.jpg”>Click here to view
index.html.</a>
</body>
</html>
In the preceding code, the image, button.jpg, and the text, Click here
to view index.html, points to the same HTML document, index.html. Save the
preceding code as Hyperlinks.html. The following screen shows the output when
Hyperlinks.html is viewed in the MSIE Web browser.
4.7 HYPERLINK
A hyperlink or link is a reference to data that the reader can directly follow or that is
followed automatically. It points to a whole document or to a specific element within a
document. Hypertext is text which is used with hyperlinks. A software system is used
Hyperlink: It is a reference
to view and create hypertext called as hypertext system and also to create a hyperlink to data that the reader can
for the Web sites. A hyperlink has an anchor which is the location within a document directly follow or that is
from which the hyperlink can be followed, the document containing a hyperlink is followed automatically
known as its source document. Hyperlinks are often used to implement reference
mechanisms, such as tables of contents, footnotes, bibliographies, indexes, letters and
glossaries.
Links appeared on Web page that navigates the corresponding Web pages as a
reference. If user navigates the pages to search or get the information through links,
that is also called in Web technology as hyperlink, provides a very quick journey of
Self-Instructional Material 127
Internet Markup Languages Web pages. Link is same as citation in literature. It is combined with suitable access
protocol and data networking. The syntax of creating link is as follows:
<a href=”url”>Link text</a>
NOTES The start tag contains the attributes of specified link whereas ‘Link text’ is
declared as the highlighted text that is displayed on Web page as link. The element
content could be text or graphics, for example buttons, etc. You would be able to link
from an image or other HTML element. Creating link is possible by writing the HTML
code as follows:
<html>
<body>
<p>
<a href=”feedback.htm”>Feedback</a>
</p>
<p>
<a href=”http://www.abc.com/”>Link to World Wide Web</a>
</p>
</body>
</html>
Result of the above Web code is as follows that provides the following link:
Feedback
Link to World Wide Web
After clicking on Feedback link and Link to World Wide Web you can
navigate on Feedback page and referenced Web site. If you set target=”_blank”
on the coding, the link will open a new window where referenced information resides.
So, the proper coding is written as follows:
<a href=”feedback.htm” target=”_blank” >Feedback</a>
The HTML anchor is defined by <a>, which is used to define both anchors and
hyperlinks. The href attribute is set with <a> element that defines the link as marked
with underline and generally highlighted with blue color.
Feedback
Hyperlinks point to resources that appear on the Web page. These resources can be
an HTML document, an image, a movie or a sound file, etc. The following HTML
code shows how an image is connected with link:
<html>
<body>
<p>
<a href=”feedback.htm”><img border=”0" src=”button_def.gif”
width =”65" height=”38">
</a>
</p>
</body>
</html>
NOTES
Other attributes used with tag <a> are shown in Table 4.10.
Table 4.10 Attributes of Tag <a>
Attribute Value Description
charset char_encoding Specifies the character set of a linked document.
coords coordinates Specifies the coordinates of a link.
href URL Specifies the destination of a link.
hreflang language_code Specifies the language of a linked document.
name section_name Specifies the name of an anchor.
rel Text Specifies the relationship between the current document and the
linked document.
rev Text Specifies the relationship between the linked document and the
current document.
shape default Specifies the shape of a link.
rect
circle
poly
target _blank Specifies where to open the linked document.
_parent
_self
_top
framename
In each search engine index, titled links create the popularity of your Web site by PPC
or CPC mechanisms. Users browse the sites that give the quality and volume of the
pages. You can view the referring traffic of the Web pages. Commercial organizations
make powerful linking and tagged with search engine optimization to make their
strategies about their business growth.
Note: The broken link also known as a dangling link or a dead link that takes place when the Web server
responds but when the specific page is not found. The most common broken link is known as a 404 error
representing a broken link.
4.8 ANCHORS
An anchor represents a string or text which marks the beginning and/or the end of a
hypertext link. The text between the opening tag and the closing tag is either the start
or destination (or both) of a link. Attributes of the anchor tag are as follows. Anchor: A string or text
• href: If the href attribute is present, the anchor is sensitive text and it shows which marks the beginning
and/or the end of a
the start of a link, for example <a href=”#identifier”> CLICK hypertext link
HERE...</a>.
• name:This attribute allows the anchor to be the destination of a link. The value
of the attribute is an identifier for the anchor, for example <a name=
“identifier”>...TO JUMP HERE</a>
All other attributes, such as rel and ref attributes are optional although one of
name and href is necessary for the anchor to be useful. The <a> tag defines an
anchor. An anchor can be used in the following ways:
• To create a link to another document, use the href attribute.
• To create a bookmark inside a document, use the name attribute.
The <a> element is usually referred as a link or a hyperlink. The most important
attribute of the <a> element is the href attribute which indicates the link’s destination.
By default, links appear as follows in all browsers:
• An unvisited link is underlined and blue.
• A visited link is underlined and purple.
• An active link is underlined and red.
Following code is used to represent an anchor representing Microsoft.com:
<a href=”http://www.microsoft.com”>Visit Microsoft.com!</a>
Table 4.11 summarizes the event attributes used with <a> tag.
The <table> tag is used to define an HTML table. An HTML table is divided into
rows which in turn are divided into columns. The use of an HTML table is to format the
data into rows and columns. Try the following HTML in your browser:
The <table> tag: It is used
to define an HTML table The tags used to format a table have been shown in Table 4.12.
Table 4.12 Table Formatting Tags
Tag Description
<thead> The <thead> tag is used to group the header content in an HTML table.
<tbody> The <tbody> element is used to group the body content in an HTML table
<tfoot> The <tfoot> element is used to group the footer content in an HTML table.
Advantages of Tables
HTML tables are used to format text into the row and column format. Not only the
text but also other HTML controls can be formatted using HTML tables.
Limitations of Table
In HTML tables, you cannot change the width of columns in each row. The size that is
Check Your Progress mentioned in the first row is what the table follows for column size rendering. Another
14. In HTML, how images are limitation of an HTML table is that if size of content varies then the table cell is
defined? expanded in length or width depending on the wrapping attribute used thus not displaying
15. Differentiate between inline the expected rendering.
and external images.
16. What does align specify? 4.9.1 Attributes of Table Elements
17. Define the term hyperlink.
18. What does an anchor Attributes which are supported in the tag <table> are listed in Table 4.13.
represent?
align Attribute
The align attribute is used to align a table to right or left or center into the Web
page. It sets the table in that particular location on the screen.
Changing the value of the align attribute to ‘right’ from ‘center’ will
change the table alignment to the right of the browser window. By default, the alignment
of the table is towards left.
width Attribute
The attribute width is used to set the width of the table in the screen. When this
attribute is not specified then the table sets its width according to the width of the row
containing the longest data.
border Attribute
The border attribute is used to specify the border width of the table grid. The value
as specified corresponds to the number of pixels to construct the grid. If this value is
set to ‘0’ then there will not be any visible border.
Self-Instructional Material 133
Internet Markup Languages cellspacing Attribute
The cellspacing attribute is used to specify the space between the adjacent cells
in a table in the form of pixel count.
NOTES cellpadding Attribute
The cellpadding attribute is used to specify the width of padding around a table
cell in pixels. In other words it introduces a frame of width, specified in this attribute
value around the cell. Try the following HTML in your browser:
<html>
<head>
<title>HTML table example</title>
</head>
<body>
<h3>HTML table example</h3>
<table border=”0" cellpadding=”1">
<tr>
<td bgcolor=”green”><b>Name</b></td>
<td bgcolor=”green”><b>Age</b></td>
</tr>
<tr>
<td bgcolor=”green”>Albert Einstien</td>
<td bgcolor=”green”>85</td>
</tr>
<tr>
<td bgcolor=”green”>Issac Newton</td>
<td bgcolor=”green”>78</td>
</tr>
</table>
</body>
</html>
In the first row, the alignment was set to center so that the text in all the cells in the
first row is centered. In the second row, no alignment is specified at <tr> instead the
alignment is set to the <td> level and accordingly the text is aligned. In the third row, the
center alignment is specified but the right alignment specified in <td> overwrites the
<tr> alignment.
Coloring Table with bgcolor
The bgcolor attribute can be used to specify the background color of the table
cell. When specified in the <tr> tag, it applies to the whole row and when specified
in the <td> tag, it applies to that particular cell only. If bgcolor is specified in both
the tags then the color value specified in <td> overwrites the color value in <tr>.
colspan and rowspan Attributes
The colspan attribute is used to merge the cells into one single row. The number of
cells to be merged is specified as the value of colspan attribute. The rowspan
attribute is used to merg cells into a single column. The number of cell merged is
specified as value of rowspan attribute. Try the following HTML in your browser:
<html>
<head>
<title>HTML table example</title>
</head>
<body>
<h3>HTML table example</h3>
<table border=”1">
<tr>
<td><b>Cell1</b></td>
<td><b>Cell2</b></td>
<td><b>Cell3</b></td>
</tr>
<tr>
<td colspan=”2">Cell 1</td>
<td>Cell2</td>
</tr>
</table>
</body>
</html>
Self-Instructional Material 137
Internet Markup Languages The output on the screen will be displayed as follows:
NOTES
In the second row, specifying the colspan = ‘2’ merges the two cells in
that row.
Setting Cell Width and Height
The height and width attributes are used to set the height and width of a cell,
respectively. Generally, the width parameter is not used as often as compared to
the height parameter.
Specifying the width attribute at the table level tells the browser that the table
will occupy full window width. Specifying the width attribute at the column level
specifies the column which will take how much width on screen. Generally, the width
parameter is specified in the first row only and the subsequent rows are formatted in
same width.
You can use different height and width parameters for every row. But the browser
will format the table using the first row only.
Putting Images and other Elements Inside Table Cells
Unlike text, you can place any content inside a table cell. The content can be an image,
data input control, or even a table. Table is used to render the display in a row-column
format. This formatting can be used to format any content. Try the following HTML in
your browser:
<html>
<head>
<title>HTML table example</title>
</head>
<body>
<h3>HTML table example</h3>
<table border=”0" width=”100%”>
<tr>
<td width=”20%”>TextBox:</td>
<td><input type=”text”/></td>
</tr>
<tr>
<td width=”20%”>Choice List</td>
<td><select>
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
</select></td>
</tr>
<tr>
<td width=”20%”>Checkbox</td>
<td><input type=”checkbox”/></td>
</tr>
138 Self-Instructional Material
</table> Internet Markup Languages
</body>
</html>
The output on the screen will be displayed as follows:
NOTES
You can see the difference between the display as compared to that in the
previous example. By introducing an empty column in the table, a margin is created.
Basically, it is not a margin but visually it seems like a margin. An empty column without
any text, added in the beginning does the work of creating a margin.
4.10 FRAME
With HTML frames, more than one Web page can be displayed in a single browser
window. HTML frames allow an HTML programmer to present the Web pages in
different views. Different views offer a programmer a way to keep certain information
visible while other views are either replaced or scrolled. Try the following HTML in
your browser:
<html>
<head>
<title>Frame Example</title>
</head>
<frameset cols=”50%,50%”>
<frame src=”http://www.google.com” />
<frame src=”http://www.yahoo.com” />
</frameset>
</html>
The above HTML source creates two frames in the window. It opens google.com
in one window and opens yahoo.com in the other. This way, you can view different
views in a single window.
140 Self-Instructional Material
Creation Internet Markup Languages
An HTML frame is created using the <frameset> tag. In the above example, no
<body> tag was present in the HTML source. The <frameset> tag is a
replacement of the <body> tag which defines a partition in the browser window.
NOTES
Each partition renders a different Web page containing their body separately.
If you go to any of the frame windows, right click the mouse and select ‘View
Source’, you will find that the source of both frames is different.
Tag <frameset> defines the container which will be subsequently partitioned
into the frames. Either the partition can be in rows or in columns. The above example
partitions the window into two partitions, assigning 50 per cent area to both the
frames.
The <frame> tag is used to define an actual frame in the partition. Its src
attribute points to the Web page that is needed to be opened in this frame.
Note: In the <frameset> tag, either there will be rows attribute or cols (columns)
attribute.
Try the following HTML in your browser:
<html>
<head>
<title>Frame Example</title>
</head>
<frameset rows=”50%,50%”>
<frame src=”http://www.google.com” />
<frame src=”http://www.yahoo.com” />
</frameset>
</html>
Changing the partition attribute from columns to rows in the above example has
changed the presentation view of the page. The partition which was initially divided
into columns are divided into rows now.
Note: There is no need to specify explicitly the size of the last frame. Instead ‘*’ can be used,
which tells to use the remaining width. In the above example, rows= ‘50%,50%’ is same as
rows= ‘50%,*’.
Self-Instructional Material 141
Internet Markup Languages Table 4.17 shows the attributes associated with the <frameset>tag.
Table 4.17 Attributes of the <frameset> Tag
Attribute Value Description
NOTES cols pixels Specifies the number and size of columns in a
% frameset.
*
rows pixels Specifies the number and size of rows in a
% frameset.
*
class classname Specifies a classname for an element.
id Id Specifies a unique id for an element.
style style_definition Specifies an inline style for an element.
title Text Specifies extra information about an element.
Table 4.18 shows the attributes associated with the <frame> tag.
Table 4.18 Attributes of <frame> Tag
Attribute Value Description
frameborder 0 Specifies whether or not to display a border around a frame.
1
longdesc URL Specifies a page that contains a long description of the content
of a frame.
marginheight pixels Specifies the top and bottom margins of a frame.
marginwidth pixels Specifies the left and right margins of a frame.
Name name Specifies the name of a frame.
noresize noresize Specifies that a frame cannot be resized.
scrolling Yes Specifies whether or not to display scrollbars in a frame.
No
auto
Src URL Specifies the URL of the document to show in a frame.
Class classname Specifies a classname for an element.
Id Id Specifies a unique id for an element.
Style style_definition Specifies an inline style for an element.
Title text Specifies extra information about an element.
Note: If you are using DTD to validate page, then make sure that doctype is set to frameset
DTD otherwise your page will be invalidated by the browser.
Also, the <body> tag cannot be used together with the frameset element.
HTML forms are used to take different types of user inputs and pass on the data to the
FORM: Elements are
elements which allow the server. Form elements are elements which allow the user to input data on the screen
user to input data on the via text boxes, choice lists, check boxes, radio buttons, text areas, etc. An HTML
screen via text boxes, choice form is defined using the <form> tag. When the form is submitted, then the data of
lists, check boxes, radio
buttons, text areas, etc
all the elements as defined inside the form tag is passed on to the server. Try the
following HTML in your browser:
142 Self-Instructional Material
<html> Internet Markup Languages
<head>
<title>HTML Form Example</title>
</head>
<body>
<h3>Registration Form</h3> NOTES
<form name=”registration_form” action=”register.jsp”
method=”post”>
<table border=”0">
<tr>
<td><b>First Name</b>:</td>
<td width=”20px”></td>
<td><input type=”text” name=”fname” width=”50" /
></td>
</tr>
<tr>
<td><b>Last Name</b>:</td>
<td width=”20px”></td>
<td><input type=”text” name=”lname” width=”50" /
></td>
</tr>
<tr>
<td><b>Sex</b>:</td>
<td width=”20px”></td>
< td >< i np ut ty pe = ”r ad i o” n a me =” s ex ” v al ue = ”M ” /
> Male <input type=”radio” name=”sex”
value=”F” /> Female</td>
</tr>
<tr>
<td><b>Age</b>:</td>
<td width=”20px”></td>
<td><input type=”text” name=”age” width=”50" /></td>
</tr>
<tr>
<td><b>Address</b>:</td>
<td width=”20px”></td>
<td><input type=”text” name=”address” width=”50"
/></td>
</tr>
<tr>
<td colspan=”3" align=”center”><input type=”submit”
value=”Submit”/></td>
</tr>
</table>
</form>
</body>
</html>
If you are using Apache Tomcat as your Web server then you can use the
following code as your server side page to receive the request:
<%
String fname=request.getParameter(“fname”);
String lname=request.getParameter(“lname”);
String age=request.getParameter(“age”);
String sex=request.getParameter(“sex”);
String address=request.getParameter(“address”);
out.print(“Name = “ + fname + “ “ + lname + “<br/>”);
out.print(“Age = “ + age + “<br/>”);
out.print(“Sex = “ + sex + “<br/>”);
out.print(“Address = “ + address + “<br/>”);
%>
Save this file as ‘register.jsp’ and be sure that this file is in the same folder as
your HTML page.
When the submit button is clicked, all the data on the form is posted to the server,
and the server page ‘register.jsp’ will receive the data and will process your request.
144 Self-Instructional Material
As you can see in the server side code, the request is received and the parameters Internet Markup Languages
are read by their name which were mentioned as the name of the elements in the form
in your HTML page. So, it is very important to assign unique names to all elements
which we want to post on the server side.
Note: Always use the post request, as it does not restrict any limit on the number of NOTES
parameters to be posted. Always assign unique names to elements in the form.
</body>
</html>
You will see only a button on the screen. Rest all the fields are hidden, they are
not visible on the page. When you click the submit button, these values are posted to
server to, ‘register.jsp’. If you are running on Apache Tomcat and ‘register.jsp’ is
present on your server, you will see the values which are posted to the server upon
processing this request.
Password Field
The password field is used to mask the input that you enter in a text box. You type the
actual text but it is displayed as ‘*’ on the screen. But when it is posted, its actual value
is not posted as ‘*’. The password field is used for entering passwords on the form.
Try the following HTML in your browser:
Self-Instructional Material 145
Internet Markup Languages <html>
<head>
<title>Password Field Example</title>
</head>
NOTES <body>
<form name=”example_form” action=”register.jsp”
method=”post>
<input type=”password” name=”fname” />
<input type=”password” name=”lname” />
<input type=” password” name=”age” />
<input type=” password” name=”sex” />
<input type=” password” name=”address” />
<input type=”submit” value=”submit” />
</form>
</body>
</html>
The output on the screen will be displayed as follows:
You can see on screen that anything you enter in the text box is masked. But
when you click on the submit button, the original text which you enter will be posted to
the server not the masked character. If you are running on Apache Tomcat and
‘register.jsp’ is present, then you will see the contents posted to the server when your
request is processed.
Submit Button
The submit button is used to submit data to the server. When the submit button is
clicked, the data on your form is posted to the server. It should not be confused with
a normal button. In case of a normal button, there is no action on clicking of the button.
Cascading Style Sheet
Style sheets are a form of separation of the content of HTML document and its
presentation. An HTML file contains its content and structure but does not define its
visual layout. Instead, its visual layout is defined in an external style sheet using a style
sheet language called CSS (Cascading Style Sheet). This approach is called as
‘Separation of Concern’. Your presentation semantics are separate and your content
structural semantics are separate.
CSS is a style sheet language to define the presentation semantics for a document
written in HTML. The primary aim of CSS is to separate document content from
document presentation. This separation improves content accessibility, and provides
control and flexibility over presentation specifications.
146 Self-Instructional Material
There are two ways of associating style to an element. One is to mention in the Internet Markup Languages
style attribute of the element or the second option is define the style in an external CSS
file and link the file to your HTML document.
CSS specifies a priority scheme, so that it can determine which style rule should
NOTES
be applicable if multiple rules match against a particular element.
Multi-purpose Internet W3C maintains the specifications for CSS. Mail
Extensions or MIME type (Internet Media type) text/css is registered for use with
CSS.
Prior to CSS, all the presentational semantics for a Web page were specified
only in the HTML markup. Font colors, elements, alignment, borders and sizes had to
be explicitly and repeatedly defined in the HTML markup. CSS provides the mechanism
to move all the presentational information to a separate document (style sheet) resulting
in a simpler HTML markup.
Try the following HTML in your browser:
<html>
<head>
<title>Style Example</title>
</head>
<body>
<h3 style=”color:0000ff;font-family:comic sans ms;”>Style
Example</h3>
<p style=”color:ff0000;font-family:courier;font-size:6">
Hi everybody, my name is Albert Einstien. This a demonstration
of the usage of styles for text formatting.
</p>
<p style=”color:ff0000;font-family:courier;font-size:6">
This is second paragraph, using the same style as the
previous one.
</p>
<p style=”color:00ff00;font-family:times new roman;font-
size:12">
This paragraph is formatted in a different style as
compared the previous two paragraphs.
</p>
</body>
</html>
In the above example, we defined different styles by setting inline styles for the
elements. The following is an example using CSS:
.header {
font-family:comic sans ms;
Self-Instructional Material 147
Internet Markup Languages color:#0000ff;
};
.para1{
font-family:courier;
NOTES color:#ff0000;
font-size:6;
};
.para2{
font-family:times new roman;
color:#00ff00;
font-size:12;
};
Save the above style definition as ‘theme.css’. Make sure that this file is in the
same folder as your HTML file. Try the following HTML in your browser:
<html>
<head>
<title>Style Example</title>
<link rel=”stylesheet” type=”text/css” href=”theme.css” />
</head>
<body>
<h3 class=”header”>Style Example</h3>
<p class=”para1">
Hi everybody, my name is Albert Einstien. This
is a demonstration of the usage of styles for text
formatting.
</p>
<p class=”para1">
This is second paragraph, using the same style as the
previous one.
</p>
<p class=”para2">
This paragraph is formatted in different styles
as compared to the previous two paragraphs.
</p>
</body>
</html>
Check Your Progress The output of the above HTML will be the same as in the previous example.
19. Why <table> tag is used? But in this example, we have separated the presentation semantics and the content
20. Why align attribute is semantics. If there is a need to change the presentation semantics, only the CSS file
used? needs to be changed and the change is then reflected on the screen.
21. Why <cellpadding>
attribute is used? Properties of CSS
22. Why <caption> tag is Properties of CSS are divided into several groups according to their behaviour. These
used?
groups are as follows:
23. What does HTML frames
allow? • Background
24. What is the use of • Border and outline
<frameset> tag? • Dimension
25. Why HTML forms are
used?
• Font
• Margin
148 Self-Instructional Material
• Padding Internet Markup Languages
• Positioning
• Text
• Pseudo classes
NOTES
• Write attribute names always in lower case. Check out the following code
Incorrect XHTML
<table HEIGHT=”40 %”> NOTES
Correct XHTML
<table height=”40 %”>
Here height is an attribute of table and needs to be written in lower case.
• Always write attribute values in quotes. Check out the following code:
Incorrect XHTML
<table height=40%>
Correct XHTML
<table height=”40 %”>
Here you are assigning value to attribute height, thus the need to put it in
quotes.
• You cannot minimize attributes.
Incorrect XHTML
<input checked>
<input readonly>
<input disabled>
<option selected>
<frame noresize>
Correct XHTML
<input checked=”checked” />
<input readonly=”readonly” />
<input disabled=”disabled” />
<option selected=”selected” />
<frame noresize=”noresize” />
Here is a list of the minimized attributes in HTML and how they should be written
in XHTML as shown in Table 4.20:
Table 4.20 Attributes in HTML and their Conversion into XHTML
HTML XHTML
compact compact=”compact”
checked checked=”checked”
nohref nohref=”nohref”
noshade noshade=”noshade”
Nowrap nowrap=”nowrap”
multiple multiple=”multiple”
noresize noresize=”noresize”
DHTML stands for Dynamic Hyper Text Markup Language or simply Dynamic HTML.
It is a combination of HTML, CSS, JavaScript, and Document Object Model (DOM). NOTES
DHTML can be described as the art of making interactive and dynamic HTML
documents.
DHTML allows the scripting languages to change the variables and attribute
values of the element on screen, which in turns affects the look and feel of an HTML
page. Otherwise, an HTML page is static after it is fully loaded into the browser window.
If we talk about a dynamic wee page then it has a much wider perspective and
broader concept. This includes the pages that are created by client-side scripting such
as JavaScript or by server-side scripting like Active Server Pages (ASP), or Java Server
Pages (JSP), or PHP, etc.
Here, our focus will be only on the Dynamic HTML pages created by client-side
scripting. Discussing Server side scripting is out of scope of this book.
The major disadvantage of DHTML is that it is difficult to debug and develop
Web pages due to the difference in support as extended by Web browsers for scripting
languages. A Web page may work in Internet Explorer but may not work in Safari.
Object Structure
DOM (Document Object Model) is an independent platform and a language neutral
interface that allows the scripts and programs to access/update the document content,
its structure, and style dynamically. The document can be processed after the display
and the result of processing can be re-displayed on the same page.
Dynamic HTML is a combination of HTML, CSS, Javascript, allows the document
to be dynamic. It provides you with an object-oriented model, in which, every element is
an object and is a part of the main document object which represents the Web page, and
the document object is part of the window object which represents the browser window.
The DOM defines the objects and properties for all the document elements and
the methods to access them. The HTML DOM defines a standard way for accessing
and manipulating HTML documents. The DOM presents an HTML document as a tree
structure as shown in Figure 4.1:
Table 4.22 describes the methods associated with the window object as follows:
Table 4.22 Methods Associated with the Window Object
Method Description
alert() Displays an alert box with a message and an OK button.
blur() Removes focus from the current window.
clearInterval() Cancels a timeout set with setInterval().
clearTimeout() Cancels a timeout set with setTimeout().
close() Closes the current window.
confirm() Displays a dialogue box with a message and an OK and a Cancel button.
createPopup() Creates a pop-up window.
focus() Sets focus to the current window.
moveBy() Moves a window relative to its current position
moveTo() Moves a window to the specified position.
open() Opens a new browser window.
print() Prints the contents of the current window.
prompt() Displays a dialogue box that prompts the user for input.
resizeBy() Resizes a window by the specified pixels.
resizeTo() Resizes a window to the specified width and height.
scrollBy() Scrolls the content by the specified number of pixels.
scrollTo() Scrolls the content to the specified coordinates.
setInterval() Evaluates an expression at specified intervals.
setTimeout() Evaluates an expression after a specified number of milliseconds.
The back button takes you the previous page, the forward button returns you the page
from where you went back, home button takes you the home page of the specified
Website, stop button stops the browser to load the current page and the print button lets
you print a copy of the Web page. The toolbars are available in the Web browser is
described as follows:
Back Button: This is shown by an arrow that points to left. Clicking on it brings you
back to the previous Web page you had visited.
Forward Button: This is shown by an arrow pointing to the right. Clicking on it returns
you to the page from where you just came.
Home Button: This button is recognized by the icon of home in Mozilla and the Internet
explorer and clicking on it takes you to the home page you have chosen. If no home page
is selected by you then it would bring you to a default home page that is normally a
Website of Google, Microsoft or Netscape.
Reload or Refresh Button: This loads the Web page once again. This is normally
done when all elements of a Web page are not loaded in the first attempt and file
transfer gets interrupted. Also, while downloading a Web page, data is temporarily stored
in computer memory and it is told that ‘data is cached’. On accessing this Web page
next time, the Web browser accesses it from cache instead of requesting the Web
server for retrieving this file. There are certain Web pages that are updated frequently,
as with scores of sport events, financial data or news. In such cases you do not get
current information, but by reloading it, data gets updated from the Web server.
Print Button: Clicking on it enables you to have a hard copy of current page that is
loaded in the browser.
Stop Button: This button is used to stop the browser from loading the current page.
Search Button: This button provides connection to search tools and directories of the
Websites of Google, Microsoft or Netscape.
Bookmarks or Favorites Button: Internet explorer shows Favorites button whereas
Mozilla and Netscape shows Bookmarks. This enables you to record addresses of
Websites for revisiting. On adding a URL in your list, you may come back to that Web
page by just clicking the link in the list that you have made and you need not retype entire
address.
156 Self-Instructional Material
Address Bar: This is situated either next to the toolbar or above it. Where user can Internet Markup Languages
type URL or address of the Website to visit. After entering the address here, hit the
Enter or Return key for accessing the site. Alternatively make a click on ‘Go’ or an
Arrow button situated towards the right of address box. By clicking on the small
downward triangle towards the right of Location box, a drop-down list appears showing NOTES
most recent Websites visited by you. This helps you in revisiting a site and you can select
the address instead of typing it. Figure 4.3 shows the various buttons in IC or Internet
Explorer browser.
The Menu Bar: This is located at the top of browser window. This enables you to
select things with a Web page. You may save the Web page on your hard disk or may
like to increase the text size on the page. Most of these choices are same as buttons on
the toolbar. Click once on a menu item for accessing the drop-down menu, then select
and click to perform action as desired. For example, clicking on File menu shows a
dropdown menu from which Save As option appears. You may save the Web page on
your hard disk by choosing a location with default file name given by the browser or may
choose a name as desired by you.
File menu is used to save the Web page, import or export the files too.
4.14.2 The Access Indicator
Internet Explorer or Mozilla Firefox, contain small graphics for indicating the activity of
the browser. Animation of this image indicates that the browser software as a client is
attempting to access data from a server that is a remote computer.
The Scroll Bar: There is a vertical or horizontal bar located towards the bottom side
and right side of the browser respectively. Using this you can scroll a Web page down
and up. To do this, place your pointer on arrows, up or down by using left key of the
mouse. You may drag the slider by placing the pointer on slider control and holding down
the left key of the mouse. There is a scrolling wheel is some mouse that provides an
alternative way to navigate a long Web page. In case width of a Web page is more and
can not fit the computer screen, you will find a horizontal scroll bar just above status bar.
This can be used to move Web page left or right.
Shockwave is not a development tool but it is a runtime routine. There are three different
versions of Shockwave. Two versions are runtime routines for multimedia applications
and the third version is for a graphics package.
Shockwave is a browser plug-in that enables the specific applications, such as
Macromedia Inc., Macromedia Director, Macromedia Authorware and Macromedia
Freehand to play on an Internet Web site or on an intranet. Although Shockwave is not
a development tool, it does enable the applications that have been shocked to include
Web-related commands, such as the loading of HTML pages and to become interactive
tools for the World Wide Web.
Specifically what are the three packages that can be shocked? Director is a
multimedia authoring package, Authorware is a CBT authoring package and Freehand
is a vector-based drawing package. Shockwave is a new technology and is fast improving
158 Self-Instructional Material
and expanding. Each week Macromedia posts news on updates and changes to its Internet Markup Languages
Shockwave technology, including new Macromedia products capable of being shocked
and new browsers capable of playing shocked applications.
Shockwave is an Internet browser plug-in that was developed by Macromedia to
enable users to view and interact with Web-based multimedia files. Shockwave currently NOTES
supports the platforms Director, Authorware and Freehand.
Director
Director is a powerful multimedia authoring tool. It has two components, a design package
capable of creating sophisticated animations and an extremely powerful programming
language, called Lingo. Lingo contains the core of Director’s power and adds complex
interactive and decision-making components to an already robust design tool.
To add a shocked movie to an HTML document, you use an HTML EMBED tag
which comprises several components.
<EMBED SRC>
The tag begins with <EMBED SRC=”??????”.
Here SRC= refers to the source or filename of the shocked file to appear (that is,
to be embedded) on the Web page.
PALETTE
Director uses the PALETTE= tag, followed by either foreground or background, for
example PALETTE=foreground. Foreground causes Director to load the specified
palette. The palette is then used for the whole Web page. Background causes Director
to ignore its internal palette(s) and to use the computer’s system palette. If you do not
include the EMBED tag, Director uses PALETTE=foreground as the default. If you
do include the EMBED tag, PALETTE=background is also the default. As with all
HTML tags, the EMBED tag ends with >.
If your browser does not support shocked files, you will see a broken icon on your
Web page. You can avoid broken icons simply by using JavaScript. For this knowledge
of Java program is not required, you have to follow a simple template. JavaScript is a
programming language that is built into Netscape Navigator 2.0. The key to JavaScript
is HTML comment tags, <!—> and <—>. All other browsers ignore the comment tags
except Netscape 2.0. When Netscape 2.0 sees a comment tag that is prefaced by
<SCRIPT LANGUAGE=”JavaScript”>, it will read the information inside the
comment tags. The format for Shockwave files is as follows:
<SCRIPT LANGUAGE=”JavaScript”>
<!— Information inside this comment area is only
recognized by Navigator 2.0.
document.write( ‘<EMBED SRC=”shockedfile” WIDTH=x
HEIGHT=y>’ );
<!— This ends the hidden JavaScript from non-Navigator
2.0 Browsers —>
</SCRIPT>
Because JavaScript is hidden with a comment section, only browsers capable of
reading JavaScript will see and display the shocked image. Developers can create
multimedia applications using just the design and animation portion of the Director package.
Self-Instructional Material 159
Internet Markup Languages Most developers use Lingo to add control and interactivity to Director movies format.
Lingo, as Director’s programming language, adds the capability of clicking buttons,
branching choices, controlling animations, and much more.
Even though Lingo has over 200 commands, numerous additional Web-related
NOTES commands and extensions have been added to the Lingo language for creating shocked
Websites. These extensions can be divided into asynchronous operations and functions.
getNetText uri
getNetText uri is the Lingo command that retrieves an HTTP text item for Lingo
to read.
Although Lingo is not case sensitive, but protocols specify that all Lingo commands
must be written in lowercase and beginning all other words within a group command
phrase in uppercase, for example, startAnimation or mouseDown.
The uri portion of the command refers to the Universal Resource Identifier
(URI). Universal Resource Locators (URLs) are a subcategory of URIs, as are file
extensions. An example of the getNetText uri command is:
getNetText “http://myWebsite.com/newsletter.text”
The NetDone command determines if the getNetText command has
finished. The uri defines the location and name of the specified text.
gotoNetPage uri, target
gotoNetPage uri is a Net-related Lingo extension that opens a new URI. It can
be another MIME type, such as an HTML page. The target parameter is optional. It
references a target frame if you have designed a page using the Netscape frame feature.
preloadNetThing uri
The preloadNetThing uri Lingo command preloads an HTTP item into Netscape’s
disk cache so that you can access or download the item without any delays. An example
of a preloadNetThing command is:
preloadNetThing “http://myWebsite.com/graphics/
logo.gif”
Functions
Functions return a result based upon the preceding asynchronous commands. Macromedia
added to Lingo a small group of functions that are specific to the Internet. They are
referred to as net functions and are identified by the inclusion of the letters net in
their name.
netDone()
If the asynchronous operation is complete, netDone() returns a result of TRUE.
netDone() returns a result of FALSE if the operation has been started, but has not
finished. The netDone() command defaults to TRUE. An example of the netDone()
function is as follows:
If netDone() then puppetSound “Trumpet”
netError()
netError() returns one of following three results:
• If an operation has not finished, n e t E r r o r ( ) returns an empty
(netError()=EMPTY) string.
160 Self-Instructional Material
• If an operation has completed successfully, netError() returns OK Internet Markup Languages
(netError() = “OK”).
• If an operation has not completed successfully, netError() returns a string
that describes the error.
NOTES
netTextResult()
netTextResult()returns the result of the getNetText command. An example
of this command is as follows:
If netDone() then
put netTextResult() into field “Headline”
end if
netMime()
netMime()returns the MIME type of an HTTP item. Only Director 5 shocked files
support this function.
netLastModDate()
netLastModDate() returns the last modified date string located in the HTTP header
for the item referenced. An example of this function is as follows:
put netLastModDate() into field “Page Updated On”
Only Director 5 shocked files support this command.
getLatestNetID()
getLatestNetID() returns a unique identifier describing the last asynchronous
operation started. This function is handy when using the netAbort command or the
netDone() function.
XObjects, XCMDs, XFCNs
XObjects, XCMDs and XFCNs refer to external objects, commands and functions.
Although both Windows and Macs can use XObjects, only the Mac can use XCMDs
and XFCNs. XObjects enable third-party developers to create new features and
enhancements for Director 4.0x.
XObjects, XCMDs, and XFCNs can be either internal (included within a Director
movie) or external (referenced or pointed to by a Director movie). Shocked movies
support only external XObjects, XCMDs and XFCNs. In order for a movie to use
external Xobjects, XCMDs or XFCNs, these files must be located in the user’s Plug-
In directory.
Authorware
Authorware is Macromedia’s icon-based authoring package. Because of its inherent
features, it is primarily used to develop CBT. Like Director, Authorware supports very
sophisticated interactivity, including the use of clickable buttons or graphics (hotspots).
Currently, Shockwave works only with Authorware 3.5 and on Netscape 2.0 or 2.01.
Although Authorware shocked applications can be used either on the Internet or
on intranets, Authorware is currently targeted primarily for use with intranets. Authorware
uses the Afterburner tool to convert Authorware applications into shocked applications.
Afterburner is available both for Windows and Mac. Afterburner performs the following
three functions:
1. It compresses Authorware files and libraries.
2. It divides the files into several segments.
Self-Instructional Material 161
Internet Markup Languages 3. It creates one map file for locating each segment when needed. Map files
are explained later.
The file segments, the map and the flattened external files are assigned MIME
types.
NOTES
application/x-authorware-map MIME type for the Authorware map.
Option Meaning
_blank
Causes the Authorware application to remain in a
window while a second window displays the new Web
page. You can use this method to return to the
Authorware application after viewing the Web page.
_self
Causes the new Web page to open in the same window
as the current page.
_parent
Causes the new Web page to open in the same frameset
parent window as the current page. When you are using
target windows, this option overrides a globally
assigned base target (the default window). If there is
no parent, this argument functions the same as the
_self argument.
_top
Causes the new Web page to open in the body of the
current window. This option is equivalent to the _self
argument. It is also used to return from frame nesting.
If you do not include a second argument, the
Authorware application closes as soon as it locates the
new Web page.
The NetDownload(URL) function downloads the file listed in (URL) to the user’s
computer. The full pathname is returned if the operation was successful. This function,
in combination with the onDemand flag in the map file, enables files to be downloaded
only when requested. NOTES
NetDownload(URL) looks at the map file and downloads to the location listed
by the put line of the map file that precedes the line entry for the file being downloaded.
If the map file does not have an entry for the file being downloaded, it will be downloaded
to the DOWNLOAD subfolder of the folder containing the Authorware plug-in.
NetPreload(IcondID@”IconTitle”)
NetPreload(IcondID@”IconTitle”) is an asynchronous command that
downloads whatever segment files the icon specified by IconTitle requires to execute.
If the IconTitle is a map, interaction, decision, or framework icon, all icons that are
either attached to (external) or within (internal) the IconTitle are preloaded.
The primary function of the NetPreload function is to initiate background
preloading of segments required for sounds, movies or graphics, so that the segments
are on the user’s system when needed.
NetConnected
NetConnected is a flag variable (1=TRUE, 0=FALSE). It tells the Authorware
application if it is running via Shockwave. The value is 1 if the application is running
under Shockwave and 0 if it is running either under Authorware’s runtime routine or in
the authoring environment. This variable is useful with calculation icons or decision
icons to branch according to the environment on which the Authorware application is
playing.
NetLocation
The NetLocation flag returns the URL of the current Shockwave application. A
useful routine is to use the NetConnected flag to determine if the Authorware
application is running on the Internet or as a stand-alone application. Then, either retrieve
a file off the HTTP server in a file relative to the NetLocation if the application is
running on the Internet or retrieve the file off the hard drive or a CD-ROM using a local
address if the application is running in stand-alone mode.
Freehand
The absolute Macromedia application that a Shockwave plug-in has ported to the Internet
is Freehand. Freehand is a cross-platform, vector-based drawing package that integrates
special effects via Xtras plug-ins, such as Smudge, Fisheye Lens and 3D Rotation,
along with powerful page layout potentials to programs, such as PageMaker and
QuarkXPress. You can use Freehand to create exciting page-based documents. With
the inclusion of Shockwave, these pages can appear on the Web. When a graphic is
created in Freehand, you can use Freehand’s Page inspector to determine the page size.
LINGO
Lingo is a scripting language developed by John H. Thompson for Adobe Director
(formerly Macromedia Director) specifically used for regular desktop applications,
interactive kiosks, CD-ROMs and Adobe Shockwave Internet Websites.
Syntax
When Lingo was created, a wordy or verbose syntax was designed to write whole
HyperTalk like sentences such as:
Self-Instructional Material 163
Internet Markup Languages if sprite 5 is visible then go to the frame
In the above syntax, with go to statement to is optional. Lingo was also
initially very robust by providing object generation through a notion called factory,
which led to the language’s extensibility through External Factories XFactories or
NOTES XObjects.
Although it is still possible to use the verbose syntax, the current version of the
language fully supports dot syntax, so that the code looks more like standard programming
languages, such as JavaScript or C++. The equivalent in new scripting style is as follows:
if sprite(5).visible then _movie.go(_movie.frame)
This format uses elements of the Director Object Model (DOM), introduced in
Director MX 2004.
Lingo is embedded into Adobe Director. Lingo is an Object Oriented Programming
(OOP) language. The following are three types of scripts in Lingo:
• Behavior scripts are attached to a sprite or inserted into a frame. Sprite behaviors
are often used to give control of the sprite’s properties and movement. Frame
behaviors can be used to create a pause or delay within a certain frame in the
score. Behaviors make it easy to program in an object oriented way. They can
also control or interact with other sprites, making them a true object.
• Movie scripts can neither be attached to sprites nor can they be instantiated as
objects. They are available throughout the program (movie) and are especially
useful for holding global handlers and initializing global variables at the start or
end of the movie.
• Parent scripts are used to create instances of (birth) an object into a variable
using the new command. These objects can control sprites and other media
remotely without being attached to any one sprite. It can be used to control data
or other non-displayed items and are useful for recursion routines, such as path
finding. A parent script can be used to create or destroy an object at anytime,
freeing them from the confines of the score that a behavior is limited to.
Behavior and parent scripts support object oriented programming paradigm.
Movie scripts are not OOP oriented, however they can still be used to make black-box
handlers where other objects can input raw data and receive answers back without
knowing the inner workings of the box.
Lingo supports object inheritance by a slightly idiosyncratic system such that a
script can have an ancestor property which references another object usually also a
script although other objects, such as cast members can also be ancestors. Properties
and methods of the ancestor are inherited by the parent. Behavior scripts are also a kind
of ancestor of the sprites to which they are attached, since properties and methods of
the behavior can be accessed by reference to the sprite itself. Thus it refers a kind of
multiple inheritance as one sprite may have several behaviors.
XObjects
Lingo was also extensible through External Factories XFactories or XObjects
later called Lingo Xtras, which provided programmatic extensions to Director, for example,
controlling external media devices, such as CD-ROM and Video tape players through
Macintosh serial port. XObject API was openly available to developers and media
device producers, which added to the popularity and versatility of Lingo. Macromind
was very active in positioning the XObject API as standard for external media
devices. Lingo was quickly adopted by growing multimedia community and the already
popular Micromind Director product.
164 Self-Instructional Material
Internet Markup Languages
4.16 NETSCAPE EXTENSIONS
Netscape extensions focus primarily on making documents appear enhanced. They are
an excellent method to improve the appearance and impact of a home page in an NOTES
increasingly Netscape dominated Web. Netscape extensions should be avoided when
publishing reports, articles and other items where the textual content is more important.
They could cause problems when HTML 3 is finalized. The following are some important
features of Netscape extensions:
• New tags include NOBR, WBR, FONT, BASEFONT, CENTER and BLINK.
• Many other tags have new attributes to provide more control over the appearance
of text and graphics.
• Tables are supported.
• Documents can include tiled image backgrounds and you can change the color of
text on a document.
Netscape extensions are unauthorized additions to the HTML 2.0 standard.
Originally the Netscape extensions only worked with the Netscape Navigator browser.
However, Mosaic 3.0+ browsers will support many of the Netscape extensions. If you
use Netscape extensions in your document you should indicate this at the top of your
document. Even though unauthorized, the Netscape extensions have become commonly
excepted tags and are used in many Web documents.
<CENTER>...</CENTER>
This is the center tags and is one of the most popular Netscape extensions. The
<CENTER> tag allows you to center text and graphics on a page. The banner image
and divider bars on this page are all centered using the <CENTER> tag. <HR> tag
attributes Netscape allows you to manipulate the size and width of the LINE RULE
tag. The SIZE attribute indicates the thickness of the rule line (the default is 2). The
WIDTH attribute with ALIGN allows you to indicate the horizontal width of the rule
line, either in pixels or as a percent of the page. The display resolution of the screen will
affect the display.
o <HR ALIGN=CENTER WIDTH=80%
o <HR ALIGN=CENTER WIDTH=40%
o <HR ALIGN=CENTER WIDTH=20%
o <HR ALIGN=CENTER WIDTH=10% Check Your Progress
Unordered List Tag Extensions: The following are the unordered list tag 26. How an XHTML document
is divided?
extensions:
27. What is DHTML?
• TYPE=DISC: This is used for a solid bullet, the default is </LI>.
28. What does DHTML allow?
• TYPE=CIRCLE: This is used for a hollow bullet. 29. What is DOM?
• TYPE=SQUARE: This is used for a square hollow bullet. 30. What does HTML DOM
define?
Ordered List Tag Extensions: The following are the ordered list tag extensions:
31. What is Internet Explorer?
• TYPE=1, this is the default which labels the list item with numbers (1, 2, 3). How it works?
• TYPE=A, this orders list items with capital letters (A, B, C). 32. What is Shockwave?
• TYPE=a, this orders list items with lower case letters (a, b, c). 33. What are Netscape
extensions? When these are
• TYPE=I, this orders the list items with capital roman numerals (I, II, III). avoided?
• TYPE=i, this orders the list items with lower case roman numerals (i, ii, iii).
Self-Instructional Material 165
Internet Markup Languages <FONT>...</FONT>
The <FONT> tag encloses text and prescribes the font size. This tag is controversial.
By assigning font size, the Netscape extension begins to control the format of a document
and may undermine the flexibility and portability of HTML. The values of font size that
NOTES can be assigned are 1 to 7 as shown below:
Font 1 <FONT SIZE=1>Font 1</FONT
Font 2 <FONT SIZE=2>Font 2</FONT>
Font 3 <FONT SIZE=3>Font 3</FONT>
Font 4 <FONT SIZE=4>Font 4</FONT>
Font 5 <FONT SIZE=5>Font 5</FONT>
Check Your Progress
34. Fill in the blanks with
Font 6 <FONT SIZE=6>Font 6</FONT>
appropriate words. Font 7 <FONT SIZE=7>Font 7</FONT>
(a) The client/application
which submits an HTTP You can also specify font size in relative terms by using the ‘+’ or ‘−’ characters.
request to a server is The font will change relative to the default font size of your browser. This extension is
referred as an
used with utmost care otherwise it may cause problems for the users. For example, if a
______________ .
user has set their browser for 16 pitch Time Roman because they need larger print then
(b) The size value is an
integer that specifies the the font with a minus value might cause them difficulty in reading the text and the
font size positive values may cause the text to be too large on their screen.
in______________
point. Relative font size:
(c) HTML colors are Font +3 <FONT SIZE=+3>Font +3</FONT>
defined using a
________________ Font -3 <FONT SIZE=-3>Font -3</FONT>
notation for the Backgrounds
combination of RGB
color values. The background attributes permits to add images as backdrops to your document, as
(d) The multimedia objects well as manipulate the background color, text and link colors of a document. The most
can be installed by important thing to consider when using these tags is the readability of the documents.
_______________ There are many examples of the improper use of these tags on the Web. Background
element that includes
multimedia content with attributes are inserted into the <BODY> tag as follows.
HTML document. • <BODY BACKGROUND=”../image/purple.gif>: This element tells
35. State whether the following the browser to find the file ‘purple.gif’ in the image directory and display it
statements are true or false. as a background.
(a) One can also insert
comments into the • <BODY BGCOLOR=”#E5E2FF”>: This element tells the browser to display
HTML file and these the background color as something other than the default background (grey). The
comments will not BGCOLOR attribute can be used as an alternative to the BACKGROUND attribute
display on the browser.
if the users are running 14.4 modems. Other attributes that can be added are as
(b) Superscript text appears
half a character below
follows:
the baseline. TEXT: It controls the color of all the regular text in the document.
(c) Transparency can be LINK: It controls the color of the normal unvisited links.
brought in an image
using the style property VLINK: It controls the color of the visited links.
of the filter. ALINK: It controls the color of the link when the user presses the mouse
(d) An e-mail message button on the link
consists of three
components, the <BLINK>...</BLINK>
message envelope, the
message header and the The <BLINK> tag cause the text to blink on and off. Depending on the version of
message body. Netscape the users are using, either the text itself will blink or a white block will blink on
and off behind the text. This tag is used to call attention to a specific item.
166 Self-Instructional Material
Internet Markup Languages
4.17 SUMMARY
• In 1989, Tim proposed a hypertext system based on the Internet and by end of
1991, wrote the first specifications for HTML which contained 20 elements. NOTES
Thirteen of these elements still exist in HTML 4. HTML specifications are
maintained by the W3C (World Wide Web Consortium).
• HTTP uses TCP/IP for reliable transport, i.e., the transfer of Web pages from
server to client over HTTP is done on TCP/IP layer. HTTP is not constrained to
use TCP/IP, it can use any Internet protocol that provides reliable transport.
• For HTTP protocol, this matrix is unknown as it relies on TCP/IP for the connection
between two machines in different networks. HTTP can work over any protocol
that provides a reliable transport.
• HTML pages are written in the form of HTML elements. HTML elements are
tags, surrounded by angle brackets ‘<’ and ‘>’, which act as indicators to a Web
browser as to how, the document is to be interpreted by the browser and ultimately
presented on the user’s computer screen.
• Attribute alink is an attribute of the <body> tag. The value of this attribute is
a color value specified either by its standard name or by its RGB value. It renders
all the links present in the Web page of the specified color value.
• Tags which are used to format the edited text in the HTML document, such as
<del> defines text that has been deleted from a document whereas <ins>
defines text that has been inserted into a document.
• An unordered list starts with the <ul> tag. Each list item starts with the <li>
tag. The list items are marked with bullets. An ordered list starts with the <ol>
tag. Each list item starts with the <li> tag. The list items are marked with
numbers.
• The <a> element is usually referred as a link or a hyperlink. The most important
attribute of the <a> element is the href attribute which indicates the link’s
destination. By default, links will appear in all browsers.
• A URL’s appearance, cookie preferences and default home page are controlled
by your browser settings. A URL is a protocol that is used to identify a Web site.
According to Web Developer Notes, a URL includes the protocol (HTTP), host
name (WWW), domain name and domain type.
• The <tr> tag is used to define the row in an HTML table, and the tag <td> is
used to define a column in the row inside a <tr> tag. It is recommended to keep
the same number of columns in all rows otherwise some browser may not render
the table properly.
• The border attribute is used to specify the border width of the table grid. The
value as specified corresponds to the number of pixels to construct the grid. If
this value is set to ‘0’ then there will not be any visible border.
• XHTML means ‘eXtensible HyperText Markup Language’. It can be interpreted
as ‘the stricter and cleaner version of HTML’.
• In case of XHTML, all elements must be nested within the <html> root element.
All other elements in XHTML are sub-elements or children of the root element.
Other elements can further have sub-elements.
• DHTML stands for Dynamic Hyper Text Markup Language or simply Dynamic
HTML. It is a combination of HTML, CSS, JavaScript, and Document Object
Self-Instructional Material 167
Internet Markup Languages Model (DOM). DHTML can be described as the art of making interactive and
dynamic HTML documents.
• The major disadvantage of DHTML is that it is difficult to debug and develop
Web pages due to the difference in support as extended by Web browsers for
NOTES scripting languages.
• DOM (Document Object Model) is an independent platform and a language
neutral interface that allows the scripts and programs to access/update the
document content, its structure, and style dynamically.
• According to DOM, everything in an HTML document is a node, even the text
and comments are nodes, termed as ‘Text Nodes’ and ‘Comment Nodes’
respectively.
• Internet Explorer is a series of graphical Web browsers developed by Microsoft
and included as part of the Microsoft Windows operating systems.
• Each of the browser available today consists of three parts, a controller, client
protocol and interpreters, and so the Internet explorer.
• Shockwave is not a development tool but it is a runtime routine. There are three
different versions of Shockwave. Two versions are runtime routines for multimedia
applications and the third version is for a graphics package.
• Shockwave is a browser plug-in that enables the specific applications, such as
Macromedia Inc., Macromedia Director, Macromedia Authorware and
Macromedia Freehand to play on an Internet Web site or on an intranet.
• Lingo is a scripting language developed by John H. Thompson for Adobe Director
(formerly Macromedia Director) specifically used for regular desktop applications,
interactive kiosks, CD-ROMs and Adobe Shockwave Internet Websites.
• Netscape extensions focus primarily on making documents appear enhanced.
They are an excellent method to improve the appearance and impact of a home
page in an increasingly Netscape dominated Web.
• Netscape extensions should be avoided when publishing reports, articles and other
items where the textual content is more important. They could cause problems
when HTML 3 is finalized.
1. The Web Server which stores HTML files and resources is known as origin
server.
2. Proxies are servers which act as a proxy for you over the network and hide the
network behind it.
3. The HTML documents are delivered from a Web server to a client via the HTTP
protocol running over TCP/IP.
4. All HTML file uses .html or .htm as file name extension. This extension uniquely
identifies an HTML file and associates them directly to the Web browser.
5. HTML elements can be described as tags surrounded by angle brackets ‘<’ and
‘>’, which are interpreted by the browser to perform a specific formatting.
6. An HTML file has two sections HEAD and BODY. The HEAD part is described
by content between the <head> and </head> tag, while the BODY part is
described by the content between <body> and </body> tag.
168 Self-Instructional Material
7. The <html> element is also known as the root element. Internet Markup Languages
Short-Answer Questions
NOTES
1. What are the advantages of HTML?
2. What are the devices used over the Internet?
3. Name the HTML file name extension.
4. Write the main features of HTML.
5. What does <font> tag specify?
6. Write the function of <sup> tag.
7. What does <dl> define?
8. What is hyperlink?
9. What are anchors?
10. What is cellspacing attribute?
11. Why colspan attribute is used?
12. Name the tag which is used to create HTML frame.
13. Why submit button is used?
14. Write the two ways of associating style to an element.
15. Why text properties are used to set the behavior of the text?
16. What is XHTML?
17. What are the various components of an XHTML document?
18. What is the significance of DHTML?
19. Name some latest Microsoft Internet Explorers.
20. What is an access indicator?
21. What is Lingo?
22. When are Netscape extensions used?
Long-Answer Questions
1. Describe the basic tags of HTML with the help of examples.
2. How a simple page is designed? Explain with the suitable program code.
3. Discuss the process of creating an HTML document.
4. Differentiate between essential and deprecated tags with the help of examples.
5. Discuss the difference between alink and vlink with the help of example
program codes.
6. How color and background are set for Web pages? Explain with the help of
examples.
7. Discuss lists and their types using suitable examples.
8. Explain the attributes of <image> tag with the help of examples.
9. Write an HTML code to insert image on Website.
10. Describe the working of Web with the help of examples.
11. Discuss the common URL schemes used in HTML.
Self-Instructional Material 171
Internet Markup Languages 12. Write a HTML code to create a table.
13. Explain the process of coloring table using bgcolor tag.
14. Write a HTML code to create a frame.
NOTES 15. Discuss the significance of password field with the help of an example.
16. Why is XHTML used extensively nowadays? Explain with the help of an example.
17. Discuss the various characteristics of XHTML.
18. Explain the steps required to convert HTML to XHTML.
19. Discuss the advantages and disadvantages of using Dynamic HTML.
20. Explain the properties and methods as per DOM specifications.
21. Discuss the anatomy and features of a Web Browser toolbar.
22. Explain the significance of Microsoft Internet Explorer. List all the popular ones
along with the version.
23. Discuss the significance of Shockwave and Lingo.
24. Explain the commands and functions used in Shockwave with the help of syntax
and examples.
25. Discuss the three types of scripts used in Lingo.
26. Explain the important features of Netscape extensions.
27. Explain the significance of various Netscape extensions tags that are used in
many Web documents along with the results.
5.0 INTRODUCTION
In this unit, you will learn about the basics of ActiveX Controls. Servers can be
implemented as ActiveX DLL or ActiveX EXE components. The difference lies in
how the server is executed. An ActiveX DLL is an in-process server. The DLL is
loaded in the same address space as the client executable that calls the server and it
runs on the same thread as the client. An ActiveX component is basically a user defined
executable control that can be used to create interfaces and applications like other
controls, such as TextBox and CommandButton. ActiveX components allow
programmers to reuse these user defined controls to perform manipulation on various
data types in their applications. ActiveX components are saved as a file with .exe,
.dll or .ocx extensions. Finally, you will learn about Web based mail which is a
implemented as a Web application accessed via a Web browser.
NOTES
Fig. 5.1 The Visual Basic Screen after starting a New ActiveX Control Project
NOTES
Look in the Properties window: The new control instance has been given a
default name, FancyCmdButton1, and it has its own set of properties. Change
Self-Instructional Material 181
ActiveX Controls the Name property to FCB1 (for the sake of brevity). To take the ActiveX control
out of the run mode and back into the design mode, double-click on its name in the
Project window. When the ActiveX control designer opens up again, you will see that
the instance of the control on the test project form becomes hatched, indicating that
NOTES the control is no longer active. This is shown in Figure 5.6.
ActiveX Control Events
You will discover one difference between ActiveX controls and standard executable
programs: An ActiveX control has a defined behaviour not only during execution
(when it is executing within its container) but also at design time. To illustrate
this, open the UserControl’s Resize procedure and add the following line to
the existing code:
Debug.Print “Resize event”
Close the ActiveX control designer to run the ActiveX control. On the test
project form, change the size of the FancyCmdButton control. You will see by the
messages displayed in the Immediate window that its Resize event procedure fires
each time you resize the control, even though the test project is still in the design mode.
If you add a second instance of the FancyCmdButton control to the form, you
will see that the Resize event fires then, too. Delete the second control—if you
placed one—before continuing.
Fig. 5.6 When the ActiveX Control is Placed Back in the Design Mode,
the Instance on the Test Project Form displays a Hatch Pattern
Now consider some of the other events that occur during the life of an ActiveX
control. When working with these events, you must understand the ephemeral nature
of an ActiveX control. You may think that once an ActiveX control is placed on a
form, that’s it; the control is created and continues to exist as a component of the form
from then on. Things are not so simple.
When you place an ActiveX control on a Visual Basic form during program
design, an instance of the control is created in memory. When you run the program,
that instance is destroyed and a new run-time instance is created; it is this instance that
will be in operation as the program executes. When you terminate the program to
return to the design mode, the run-time instance of the control is destroyed, and yet
another instance is created and displayed on the form in the Visual Basic designer. As
you can see, rather than having a single instance of the control remaining, three have
actually been created and destroyed.
182 Self-Instructional Material
For example, suppose you have designed an ActiveX control in Visual Basic ActiveX Controls
and created a test form. When you close the ActiveX designer and place an instance
of the control on the test form, you create an instance (as described in the previous
paragraph). If you then reopen the ActiveX designer so that the control on the test
form is displayed with hatching, the control instance is destroyed. When you close the NOTES
ActiveX designer, a new instance of the control is created and the control on the test
form is displayed without hatching.
If you place two or more instances of a control on a form, each instance
undergoes its own creation–destruction–creation cycle.
It is rather complicated. You will feel more comfortable with it after a while,
particularly after some programming techniques are presented later in this unit that will
assist you in keeping track of the creation and destruction of control instances. For
now, what you should remember is that an ActiveX control has certain events that are
triggered in response to control creation and destruction. Some of these events have
to do with the control’s properties—a topic we will be discussing later. For now, let us
just look at the events without worrying about the details:
• Initialize—Occurs each and every time an instance of the control is
created. It is always the first event that occurs for the control.
• InitProperties—Occurs only when the control is placed on a form; in other Initialize: Occurs each and
words, the first time an instance is created. You can use this event procedure every time an instance of the
to set a control’s initial values. control is created. It is
always the first event that
• ReadProperties—Occurs the second and subsequent times an instance of occurs for the control
a control is created. In other words, this event occurs every time a control
instance is created except the first time (when InitProperties occurs
instead).
• Resize—Occurs every time a control instance is created and every time its
size is changed, either by the programmer in the design mode or by the code
during program execution.
• Paint—Occurs whenever the control’s container tells the control to redraw
itself. If you are creating your control’s visual appearance with drawing
methods, the code should go in this event procedure.
• WriteProperties—Occurs during design time when an instance of the control
is destroyed and at least one of its properties has been changed.
• Terminate—The last event to occur when a control instance is destroyed.
To get a handle on when these various control events occur, you can use the
same technique that you used earlier for the Resize event procedure: Place a
Debug.Print statement in each event procedure to print the appropriate message
to the Immediate window. The code is shown in Listing 5.2. With this code in your
ActiveX project, you can trace events as they occur during the lifetime of your ActiveX
control.
Listing 5.2 Using the Debug.Print Statement to Track the Occurrence of Event
Private Sub UserControl_Initialize()
Debug.Print “Initialize event”
End Sub
Private Sub UserControl_InitProperties()
Debug.Print “InitProperties event”
Self-Instructional Material 183
ActiveX Controls End Sub
Private Sub UserControl_Paint()
Debug.Print “Paint event”
End Sub
NOTES Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Debug.Print “ReadProperties event”
End Sub
Private Sub UserControl_Terminate()
Debug.Print “Terminate event”
End Sub
Private Sub UserControl_WriteProperties(PropBag As
PropertyBag)
Debug.Print “WriteProperties event”
End Sub
Responding to Events
When dealing with ActiveX controls, you have to consider events occurring at three
levels:
• The constituent controls used to create the ActiveX control, such as the Shape
and Label controls in the demonstration project, may need to respond to events.
• The ActiveX control may need to respond internally to events, such as the user
clicking on the control.
• The container object may need to respond to events that occur to the ActiveX
control.
If you think about this for a moment, you can see that events may need to be
‘passed along’ from one object to another. For example, if the user clicks on the Label
control in the demonstration ActiveX control—and you want the container object to
be able to respond—pass the event ‘up’ to the container. This is accomplished using
Visual Basic RaiseEvent statement. The syntax is as follows:
RaiseEvent EventName [(ArgList)]
EventName is the name of the event to fire and ArgList is an optional list
of arguments. Before you can use RaiseEvent, you must declare an event procedure
for the event you will raise. This declaration must be at the module level of the module
in which the event will be raised; it takes the following form:
[Public] Event EventName [(ArgList)]
EventName and ArgList are, respectively, the name of the event and an
optional argument list. Include the optional Public keyword if the event needs to be
detected by another module; otherwise, it will be available only within the module
where it is raised. When the event is raised, the argument list used in the RaiseEvent
statement must match the list in the event procedure declaration.
What events are available? The usual repertoire of Visual Basic events is at
your disposal, such as Click and MouseDown. Without RaiseEvent, the control
would be able to use events internally, but if you want the container to be able to
respond to events, you will have to raise them. Before we write the event code for the
FancyCmdButton control, let’s think for a moment about what it needs to do:
• When the user presses the mouse button when the pointer is on the control,
the control’s background colour should change.
184 Self-Instructional Material
• When the user releases the mouse button, the background colour should ActiveX Controls
change back, and a Click event should be raised so that the container
object can respond to it.
For the first task, we will use the MouseDown event. But where will this event
be detected? The ActiveX control consists of both Label and Shape control, plus the NOTES
underlying UserControl. Clearly, the Label control must respond to MouseDown.
Shape controls do not detect mouse events, so mouse action on our Shape control
will be automatically passed through to the underlying UserControl. Thus, the
UserControl’s MouseDown event procedure will also be used. In figuring out
how to handle the first task, we learn how to do the second as well. We will use the
MouseUp event procedure of the Label control and UserControl.
Start by opening the Code window for the FancyCmdButton control. Select
General in the Object list and Declarations in the Procedure box and then add the
code shown in Listing 5.3. This code declares a variable and a constant for manipulating
the control’s colour and declares the Click event procedure, so that we can use the
RaiseEvent statement.
Listing 5.3 Code in the General Declarations Section of the ActiveX Control
Module
Option Explicit
‘Variable for the old color.
Dim OldColor As Long
‘Constant for the “clicked” color (this is red).
Const NEWCOLOR = &HFF&
‘Declare a Public Click event procedure.
Public Event Click()
The next code must be added to the MouseDown and MouseUp event
procedures of the Label and FancyCmdButton. In the Code Editing window,
use the Object and Procedure lists to select these procedures and then add the code
shown in Listing 5.4. This listing combines the code for the two MouseDown and two
MouseUp event procedures.
Listing 5.4 The MouseDown and MouseUp Event Procedures for the
FancyCmdButton and the Label Control
Private Sub lblButton_MouseDown(Button As Integer, Shift As
Integer, X As Single, Y As Single)
‘Save the original fill color.
OldColor = shpButton.FillColor
‘Change to the “clicked” fill color.
shpButton.FillColor = NEWCOLOR
End Sub
Private Sub lblButton_MouseUp(Button As Integer, Shift As
Integer, X As Single, Y As Single)
‘Restore the original fill color.
shpButton.FillColor = OldColor
‘Raise the click event.
RaiseEvent Click
End Sub
Self-Instructional Material 185
ActiveX Controls Private Sub UserControl_MouseDown(Button As Integer, Shift
As Integer, X As Single, Y As Single)
‘Save the old fill color.
OldColor = shpButton.FillColor
NOTES ‘Change to the “clicked” fill color.
shpButton.FillColor = NEWCOLOR
End Sub
Private Sub UserControl_MouseUp(Button As Integer, Shift As
Integer, X As Single, Y As Single)
‘Restore the original fill color.
shpButton.FillColor = OldColor
‘Raise a Click event.
RaiseEvent Click
End Sub
This completes the code required to have our FancyCmdButton control
respond to user clicks by changing its background colour and raising a click for its
container to respond to. The next task is to add the code to the test project, enabling
it to respond to that event. Close the UserControl, and display the Code window
for the test project form (TestAXCtl_Form1). Add the single line of code in
Listing 5.5 to the form’s Click event procedure.
Listing 5.5 The Container Form’s Click Event Procedure
Private Sub FCB1_Click()
MsgBox (“I’ve been clicked”)
End Sub
The project is now ready to be taken for a spin. Be sure that the FancyCmdButton
designer is closed, as indicated by the control on the test form displayed without hatch
marks. Also, be sure that the test project is the startup project, as indicated by its
name displayed in bold in the Project Explorer window. If it is not, right-click on the
project name and select Set As Startup from the pop-up menu. Then, press F5 to run
the test project. You will see its form displayed, as shown in Figure 5.7. When you
position the mouse pointer over the control and press the mouse button, you will see
the button’s background colour change to red. When you release the mouse button,
the colour changes back to green and a message appears indicating that the form has
detected the click.
Fig. 5.8 ActiveX Control Properties in the Visual Basic Properties Window
along with the Default Properties
NOTES
Fig. 5.9 After Adding a Property Page, a Blank Property Page is Displayed
NOTES
Fig. 5.10 The Property Page after Placing its Two Controls
Basically, you have two options for dealing with multiple selected controls. The
one you use will depend on the nature of the specific property. For some properties,
such as ForeColor, it makes sense to permit the user to change the property setting
for two or more controls at once. Note that ForeColor is being used here as a
generic example—it is not a property of our FancyCmdButton control. In contrast,
other properties are not appropriate for such batch changes; if multiple controls are
selected, you want to disable that property. The Caption property of our
demonstration control falls into the latter category.
Dealing with the possibility of multiple selected controls is simplified by the
SelectedControls collection, which provides a zero based index list of the
control(s) that are currently selected on the form. You can query this collection’s Count
property to see if more than one control is selected and then take the appropriate
action. For the single property on the FancyCmdButton’s property page, use the
code shown in Listing 5.7. This code is placed in the property page’s
SelectionChanged event procedure.
Listing 5.7 The Property Page’s SelectionChanged Event Procedure
Private Sub PropertyPage_SelectionChanged()
‘Enable the Text Box for the Caption
‘property only if there is a single
‘control selected.
If SelectedControls.Count = 1 Then
txtCaption.Enabled = True
‘Display the current property value on the property
page.
txtCaption.Text = SelectedControls(0).Caption
Else
txtCaption.Enabled = False
End If
End Sub
The code we have written takes care of displaying the current property value
on the property page when the page is opened. It also disables the Text Box on
the property page if more than one FancyCmdButton control is selected. We
still have to write the code that moves information in the other direction: from the
property page to the control’s actual properties. This code is divided into two parts.
190 Self-Instructional Material
First, every property page has a Changed property. You need to write a ActiveX Controls
code that sets this property to True if the user makes any changes to the properties
listed on the page. When its Changed property is True, the property page
automatically enables its Apply button, which the user clicks on to apply the new
properties to the control. The ideal place to do this is in the Text Box’s Change NOTES
event procedure, which is fired whenever the user changes the contents of the Text
Box. To add this code, be sure that the property page is displayed (if not, double-
click on FCBGeneral in the Project box). Then double-click on the single Text Box
on the page to display the code for its Change event procedure and add the code
shown in Listing 5.8.
Listing 5.8 The Change Event Procedure for the Text Box on the Property
Page
Private Sub txtCaption_Change()
‘Set the property page’s Changed
‘property to True if the user
‘changes the contents of the Text Box.
Changed = True
End Sub
Second, to apply the change, use the property page’s ApplyChanges event.
This event is fired when the user clicks on either the OK or the Apply button in the
Property Page dialog box. Your job is to place code in this event procedure that will
copy property values from the controls on the property page to the actual control
properties. The details of how this is handled will depend on the specifics of your
control, its properties, and so on. The code is simple for the single property in the
demonstration project, consisting of the single line shown in Listing 5.9.
Listing 5.9 The ApplyChanges Event Procedure
Private Sub PropertyPage_ApplyChanges()
SelectedControls(0). Caption = txtCaption.Text
End Sub
If we had permitted simultaneous changes to multiple selected controls, we
could have used the following code:
Private Sub PropertyPage_ApplyChanges()
‘Declare a generic Object variable.
Dim objControl As Variant
‘Loop through all selected controls.
For Each objControl In SelectedControls
objControl.Caption = txtCaption.Text
Next
End Sub
While we have created the property page for the FancyCmdButton control,
we have yet to connect it to the control. Here are the required steps:
1. Double-click on FancyCmdButton in the Project window to open the
designer.
2. In the Property list, scroll down to the PropertyPages property. The current
setting of this property will be (none).
Self-Instructional Material 191
ActiveX Controls 3. Click on the button with the ellipsis (...) to display the Connect Property Pages
dialog box (see Figure 5.11). The dialog lists the FCBGeneral page that we just
designed, as well as three standard property pages that Visual Basic makes
available to you.
NOTES
4. Click on the FCBGeneral property page name to display a check mark in the
box next to it, then click on OK.
Now that the property page is connected to the control, you can use it to set
the control’s properties—in this case, there is only one property. To try it out, you
must first close the Property Page designer. Just like a control, a property page must
be in the run mode to be available to its connected control. Then, double-click on
Form1 in the Project box to display the form for the test program. Right-click on
the FancyCmdButton control on the form and select Properties from the pop-
up menu. The property page we designed will be displayed as shown in Figure
5.12.
Fig. 5.12 Displaying the Property Page for the FancyCmdButton Control
192 Self-Instructional Material
Change the Caption property on the property page and, then click on either ActiveX Controls
OK or Apply. You will see the new property reflected immediately on the control on
the test form.
Compiling ActiveX Control NOTES
As long as your ActiveX control is a part of a Visual Basic project, it can be used
within that project—and only within it. To make it available to other applications, you
must compile it into an OCX file. In this section, you will be taught how to compile the
demonstration ActiveX control that we created and how to use the compiled version
in your project. To compile the ActiveX control, follow the steps given below:
• Ensure that all the parts of the project group are in the design mode.
• In the Project window, click on AXCtrlDemo to make it an active project.
• Open the File menu and select Make AXCtrlDemo.ocx. Visual Basic displays
the Make Project dialog box. If you want the OCX file in a different folder,
select it here. You can accept the default name for the OCX file, which is the
same as the project name (AXCtrlDemo). You can also assign a different
name, such as FancyCmdButton, if you wish.
• Click on OK. Visual Basic will compile the project. No message is displayed
upon completion, but if you look in the specified folder, you will find the OCX
file.
• On the File menu, select Remove Project to remove the ActiveX control project
from the project group. Visual Basic will display a warning message, because
the control is referenced from another part of the project group—but that is
okay.
Once you have compiled the ActiveX control into an OCX file and removed
the ActiveX project from the project group, Visual Basic will automatically switch to
using the compiled version in the test project. You will see that the icon for the ActiveX
control is still displayed in the Visual Basic Toolbox. You can add other instances of
control to the project’s form, access its property page, and so on.
Distributing ActiveX Control in Other Projects
When you start a new Visual Basic project, you will not automatically have access to
the ActiveX controls you have created. To add them to the Toolbox, you must select
Components from the Project menu to display the Components dialog box (see Figure
5.13). Place a check mark next to the control or controls you want available in your
project (controls you created are listed by the name you assigned). In the case of the
demonstration control, it will be listed as Fancy Command Button. At that point, the
control will be available to your project, just as any other ActiveX control.
You can distribute ActiveX control with the help of Visual Basic Package and
Deployment Wizard.
NOTES
194 Self-Instructional Material Fig. 5.14 Component Dialog Box For Adding a Controls to Toolbox
Put a check against the control, which you want to add to Toolbox. ActiveX Controls
• Click Close or click Apply and close the Component dialog when you finish
adding the controls.
Now you can see the checked control icon in Toolbox. NOTES
Visual Basic 6.0 offers us many built-in ActiveX controls of which a few are
listed and briefly explained below.
Image List Control
Image list controls are invisible controls that serve one purpose, i.e., to hold images
that are used by other controls. Usually, you add images to an image list control at
design time, using the Insert Picture button in the control’s property pages. You can Image list controls:
also add images to an image list at run-time, using the Add method of its internal image Invisible controls that serve
one purpose to hold images
collection, ListImages. that are used by other
To use the images in the image list, you usually associate the image list with a controls
Windows common control (which has an ImageList property). For each item in
the common control, such as a tab in a tab strip control, you can then specify either an
index into the image lists’ ListImages collection or an image’s key value to associate
that image with the item.
You can also reach the images in an image list with the ListImages
collection’s Picture property. For example, if you want to use an image list with a
control that is not a Windows common control, such as a picture box, you can assign
the first image in the image control to that picture box this way:
Picture1.Picture =
ImageList1.ListImages(1).Picture
The ImageList control tool appears in the Visual Basic toolbox as shown
in Figure 5.15 at the bottom, on the right.
Image List
Control
To insert images into the image list control, just use the Insert Picture button;
clicking that button lets you search for image files on disk. Each successive image gets
a new Index value, starting from 1 and counting up. If you wish, you can also give
each image a Key value (a unique text string identifier) by entering text in the box
labelled Key when you add an image. When you are done adding images, close the
property pages by clicking on OK. You can also add images to an image list using the
ListImages collection’s Add method at run-time like this, where we give the
image the key ‘tools’:
ImageList1.ListImages.Add , “tools”,
LoadPicture(“c:\tools.bmp”)
196 Self-Instructional Material
Tree View Control ActiveX Controls
If you have used the Windows Explorer, you are familiar with tree views. Tree views
present data in a hierarchical way, such as the view of directories that appears in the
tree view on the left of the Windows Explorer, as shown in Figure 5.17. NOTES
Trees are composed of cascading branches of nodes, and each node usually
consists of an image (set with the Image property) and a label (set with the Text
property). Images for the nodes are supplied by an image list control associated with
the tree view control. A node can be expanded or collapsed, depending on whether or
not the node has child nodes. At the topmost level are root nodes and each root node
can have any number of child nodes. Each node in a tree is actually a programmable
Node object, which belongs to the Nodes collection. As with other collections, each
member of the collection has a unique Index and Key property that allows you to
access the properties of the node.
Adding a Tree View to a Form
To add a tree view control to a form, follow the steps mentioned above for other
controls.
Selecting Tree View Styles
There are many different styles for tree views—text nodes only, pictures and text
nodes, showing or not showing the tree ‘lines’ that connect nodes, showing or not
showing the plus and minus symbols to expand or collapse nodes, and so on. You set
the tree view’s style using its Style property. Given below are the possible values (we
will stick to the default, style 7).
• tvwTextOnly—0 • tvwPictureText—1
• tvwPlusMinusText—2 • tvwPlusPictureText—3
• tvwTreelinesText—4 • tvwTreelinesPictureText—5
• tvwTreeLinesPlusMinusText—6
• tvwTreelinesPlusMinusPictureText—7 (the default)
Adding Nodes to a Tree View
You can add Node objects to a tree view by adding them to the Nodes collection.
How does this work? For example, we will add a node, Node1, to a tree view,
TreeView1 (the tree view’s Style property is set to tvwTreelinesPlus
MinusPictureText, the default).
First, we declare the node:
Private Sub Form_Load()
Dim Node1 As Node
...
Next, we add the node to the tree view using the Nodes collection’s Add
method (see the next topic for more information on this method):
Private Sub Form_Load()
Dim Node1 As Node
Set Node1 = TreeView1.Nodes.Add
Self-Instructional Material 197
ActiveX Controls ...
Now we can refer to the node by name, Node1, as we set its text:
Private Sub Form_Load()
Dim Node1 As Node
NOTES
Set Node1 = TreeView1.Nodes.Add
Node1.Text = “Node 1”
...
We can also refer to the node as a member of the Nodes collection as here,
where we set the node’s Key property:
Private Sub Form_Load()
Dim Node1 As Node
Set Node1 = TreeView1.Nodes.Add
Node1.Text = “Node 1”
TreeView1.Nodes(1).Key = “Node 1”
End Sub
How does this look when you run it? You can see that the result in Figure 5.18
is not very spectacular with just one node. You can add other nodes by duplicating the
preceding code and naming the new nodes Node2, Node3, and so on, but they will
all appear at the same level.
In 1996, Microsoft launched its ActiveX technology which provided a simple technique
to programmers for offering additional facilities to end-user applications. Basically,
ActiveX controls are used to provide browser enhancements, such as advanced
multimedia capabilities and can be incorporated into software, such as the Microsoft
Office family of applications. The disadvantage of using ActiveX controls is that it
enhances security risk because the programmers can hide code within an apparently
safe control to attack a user's computer.
In fact, ActiveX technology is exclusively developed by Microsoft. In it with an
ActiveX-enabled browser, i.e., Internet Explorer only ActiveX controls can be safely
downloaded as part of a Web document for adding functionality to the Web browser.
Especially, ActiveX enables faultless viewing of all sorts of Windows files in combination
with other technologies, such as Java and scripting languages that helps in the
development of complex Web applications.
An ActiveX component is basically a user defined executable control that can
be used to create interfaces and applications like other controls, such as TextBox
and CommandButton. ActiveX components allow programmers to reuse these
user defined controls to perform manipulation on various data types in their applications.
ActiveX components are saved as a file with .exe, .dll or .ocx extensions.
Reusing the built-in components aids the programmer for early software
development. ActiveX components were previously known as OLE controls. ActiveX
components allow the programmers to add functionality to the Web pages. You can
easily design ActiveX components by using the standard controls available in the Visual
Studio Toolbox. You can directly test and debug the ActiveX component code during
the designing of the ActiveX control. You can bind the ActiveX components with the
individual controls on a form to control the flow of information that needs to be
performed on the form.
NOTES
3. Select the MS Sans Serif option from the Font ComboBox, Bold option
from the Font style ComboBox and 14 from the Size ComboBox. Click
the OK button to confirm the settings.
4. Drag and drop three labels and change the Caption property to First
Name, Last Name and Birth Date correspondingly.
5. Select the Font property using the ellipses button in the Properties window
to display the Font dialog box. Select the System option from the Font combo
box and the Bold Italic option from the Font style combo box.
6. Drag and drop three TextBox from the Toolbox window.
7. Drag and drop one command button and change the Caption property
to Click Me.
8. Right click on the Toolbox window and select the Components option from
the shortcut menu. The components dialog box is displayed.
Figure 5.26 shows the Component dialog box.
9. Select the Microsoft ADO Data Control 6.0 (OLEDB) option from the
Control tab page. Click the OK button to confirm the settings.
204 Self-Instructional Material
ActiveX Controls
Note: You can see that the ADODC control is added to the Toolbox window..
10. Double click the ADODC to display it on the form and change the Caption
property to Navigate Records.
NOTES
11. Place all the controls on the form.
Figure 5.27 shows the placement of controls on the form.
12. Right click the ADODC and select the Properties option from the
shortcut menu. The Property Pages dialog box is displayed. Figure 5.28
shows the Property Pages dialog box.
13. Click the Build button to display the Data Link Properties dialog box.
Figure 5.29 shows the Data Link Properties dialog box.
16. Click the OK button to close the Data Link Properties dialog box.
17. Click the Test Connection button to verify that the connection to the access
database files has been established. The Microsoft Data Link dialog box will
display the message that the connection succeeds. Figure 5.31 shows the
Microsoft Data Link dialog box.
18. Click the OK button on the Microsoft Data Link dialog box.
Note: You can see that the Use Connection String option on the Property Pages
dialog box has now been provided with the Provider=Microsoft.Jet. OLEDB.4.0;
Persist Security Info=False value.
19. Click the RecordSource tab on the Property Pages dialog box.
20. Select the 2 – adCmdTable option from the Command Type
drop-down list and Employees option from the Table or Stored Procedure
Name drop-down list. Figure 5.32 shows the RecordSource tab page.
206 Self-Instructional Material
ActiveX Controls
NOTES
21. Click the OK button to close the Property Pages dialog box.
22. Select all the three TextBoxes on the interface and select the adodc
option from the DataSource drop-down list.
23. Select the Text1 TextBox and set the DataField property to First
Name.
24. Select the Text2 TextBox and set the DataField property to Last
Name.
25. Select the Text3 TextBox and set the DataField property to Birth
Date.
Press F5 to execute the ActiveX control. The Internet Explorer Window opens
to display the output. Figure 5.33 shows the ActiveX control.
NOTES
2. Click the Next button to display the ActiveX Control Interface Wizard – Select
Interface Members screen. This screen allows you to select single or multiple
custom properties defined for custom controls. To select custom property,
highlight the property in the Available names section and click the right arrow
button to add the property to the Selected names section.
Figure 5.36 shows the selected BackColor and DataSource properties.
3. Click the Next button to display the ActiveX Control Interface Wizard – Create
Custom Interface Members screen. This screen allows you to define some of
the custom members for the control. You can create new members by clicking
the New button. If there exists some custom members for the control, the Edit
and Delete buttons will appear enabled to modify and delete the existing custom
members.
Figure 5.37 shows the ActiveX Control Interface Wizard – Create Custom
Interface Members screen.
Fig. 5.38 The ActiveX Control Interface Wizard – Set Mapping Screen
2. Click the Finish button to close the wizard. Before closing, the ActiveX Control
Interface Wizard Summary screen is displayed. This screen summarizes the
information required to test and debug the ActiveX Control.
210 Self-Instructional Material
Figure 5.40 shows the ActiveX Control Interface Wizard Summary screen. ActiveX Controls
NOTES
3. Click the Close button to close the wizard. Open the Code window for the
interface. You can see that multiple lines of code have been generated in the
existing code for the properties which you have defined by using the ActiveX
Control Interface Wizard.
Figure 5.41 shows the Code window for the interface.
NOTES
Shell (“notepad.exe”)
Figure 5.43 shows the code for the DLL file.
NOTES
5. Save the class file with the name noteopening and the project with the name
notepad.dll.
6. Compile the file and save it in the folder where various other Visual Basic
projects are saved.
7. Select the New option from the File menu to launch a new Visual Basic
project.
8. Select the Standard EXE option from the New Project dialog box to create
a container file for the DLL component.
9. Select the References option from the Project menu to display the References
dialog box.
Figure 5.44 shows the References dialog box.
10. Click the Browse button to navigate to the DLL file to add its reference to
the exe file. Click the OK button to close the References dialog box.
Self-Instructional Material 213
ActiveX Controls 11. Drag and drop one command button on the form and change the caption to
Click Me.
12. Double click the commandButton to display the Code window and
write the following lines of code:
NOTES
Dim a As New Noteopening
a.openingnotepad
Note: Make sure you write the above code for the Click event of the commandButton.
13. Save the project and form with the names, notepad.exe and notepad.form,
correspondingly.
14. Execute the form by pressing the F5 key from the keyboard.
15. Click the Click Me button. You will notice that the notepad file is open for
you on the desktop.
Built-In ActiveX Controls
VB also provides various built-in ActiveX controls, such as Animation and
Communication which you can directly use in your programming application. The
Table 5.4 lists the various commonly used ActiveX controls:
Table 5.4 Various Built-In ActiveX Controls and Description
You need to perform the following sequence of steps to register an ActiveX component
(.ocx file). To register an ActiveX control:
1. Select Start→Programs→MS DOS Prompt to display the command prompt NOTES
window.
2. Browse the Regsvr32 file on the command prompt and enter the following
command on the command prompt window:
Regsvr32.exe Northwind.ocx
In the above command, Regsvr32 .exe is a VB tool, which is used to register
the ActiveX component and Northwind.ocx is the name of the ActiveX
component that you want to register.
3. Press the Enter key to run the command. A dialog box appears, which specifies
that the Northwind.ocx component has been registered.
Figure 5.45 shows the RegSvr32 dialog box.
One must install a plug-in or helper application as standard browsers does not
supports and display real time video and audio. VDOLive player is the plug-in that is
used to view the VDOLive video clips and is available for the Windows and Macintosh
platform which works with most of the Web browsers. This special purpose program
runs on the client machine, interprets the video stream and displays it on a screen.
VDOLive server runs in the background and listens to the request made to the
default TCP port. It then reads the file of VDO format from local file system and
transmits it over the Internet to a client using the UDP protocol.
Netscape Navigator provided a basic browser program for the Web. When Netscape
first developed their Web browser, they decided they could never provide everyone
who used it with every possible viewer for all files and they chose to open up their
platform for outside developers.
Additional programs that make Navigator even more powerful are called plug-
ins, and they provide Netscape Navigator with the ability to view non-HTML
documents. They allow the user to extend the functions in Netscape Navigator to
display multimedia, word and desktop publishing files and also features like three
dimensional viewing, and real time chatting over the Internet.
Netscape Plug-in Application Programming Interface (NPAPI) is a cross-platform
plugin architecture used by many web browsers. It was first developed for the Netscape
family of browsers starting with Netscape Navigator 2.0 but was subsequently
implemented by many other browsers as well. It also supports scripting, printing, full
screen plugins, windowless plugins and content streaming.
NOTES
• Click the index (searched result) provided by Yahoo and read the online
information.
5.6.1 Uploading and Downloading
In computer networks, downloading means to receive data to a local system from a
remote system or to initiate data transfer. Examples of a remote system from which a
download might be performed are Web server, FTP server, e-mail server, etc.
Downloading or uploading is relative to the system involved, for example a Personal
Computer PC downloads a file from a server while the server is uploading that file to
PC. A download can mean either any file that is offered for downloading or that has
been downloaded or the process of receiving such a file. It has become more common
to mistake and confuse the meaning of downloading and installing or simply combine
them incorrectly together. Screen below displays a Web page where Upload button is
provided to upload and share the content.
The inverse operation, uploading, refers to the sending of data from a local system to
a remote system, such as a server or another client with the intent that the remote
system should store a copy of the data being transferred or the initiation of such a
Self-Instructional Material 219
ActiveX Controls process. The words first came into popular usage among computer users with the
increased popularity of Bulletin Board Systems or BBSs facilitated by the widespread
distribution and implementation of dial-up access in the 1970s.
Select ‘Save’ button. You will next get a dialog box giving you a choice as to where the
file is to be saved. You can select to have it stored anywhere on your computer. It is
convenient to create temporary folder to store files you want to download. To create
this folder, follow the instructions below.
• Open Windows Explorer by clicking on Start→ →Programs→
→Windows
Explorer.
• Click on the ‘C:’ or other desired drive icon in the Window.
• Click on File→→New→ →Folder.
• Type cards32.exe for File name: bar in ‘My Downloads’ folder.
Click on ‘Save’ button. The download will now start. Your browser will tell you how
much of the file has been downloaded and how much longer it will take to download
the rest of the file.
Open the folder where you saved the file and install the downloaded program.
Uploading refers to sending of data from a local system to a remote system. like
a server to keep a copy of the data there for various purposes. Downloading refers to
retrieving of data from a remote system to a local system. Examples of remote systems
include the Web server, FTP server, email server or other similar systems. Information
220 Self-Instructional Material needs to be digitized for uploading or downloading.
In the case of uploading, the files are generally copied from a smaller peripheral ActiveX Controls
system to a larger central system. For example, a mobile phone file can be easily
uploaded to a personal computer. Similarly, files from personal computer can be
uploaded again to a server. Small files take only a few seconds in uploading, whereas
larger graphic files can take hours in uploading. NOTES
Downloading entails transfer of data from a central system to a smaller system.
It is quite palpable that larger files take more time as compared to smaller files in
downloading. Email is an interesting example of downloading and uploading in which
emails in Inbox are downloaded from a server, whereas the replies are uploaded, so
that they may be transmitted to the recipient. File Transfer Protocol (FTP) program is
used to upload files to servers as well as to download files from remote locations. A
number of programs are available to assist the users with uploading and downloading.
A custom Web application can be created to deal with multiple Internet protocols. In
this section, you will learn about the basic features of building required custom application
that will help you in enhancing your own multi-protocol based applications. The
application includes WebPOP which is a Web-based mail reader. The term Webmail
or Web-based e-mail defines a Webmail client, i.e., an e-mail client implemented as a
Web application accessed via a Web browser.
A Multi-Protocol Application
A multi-protocol application must be carefully planned before writing the program
code. The following points must be checked before writing any multi-protocol
application:
• Consider the functions that the application will provide and the protocols it
needs to use.
• Search for similar features on the Internet that may help in fulfilling the
requirements.
• Get the specifications usually an RFC or Request For Comments document of
the protocols to be used.
• Specify the sockets (communication) interface of the required programming
language.
• Create a draft of the overall design, such as subroutines and modules of the
application.
• Code the application in the specific/required language.
• Test the application by taking special care with the subroutines that implement
the different protocols.
A Multi-Protocol Application on the Web
Basically, the Web servers and Web browsers exchange information using the HyperText
Transfer Protocol (HTTP), but there are several Internet services that are based on
other familiar protocols, such as SMTP (mail), NNTP (news), FTP (file transfer), and
Self-Instructional Material 221
ActiveX Controls so on. In fact, there are various techniques for exchanging information between different
servers which can be placed under the same Web-based interface. The integration of
several protocols in single application involves a careful design process. A general
characteristic of multi-protocol Web-based applications is the use of the CGI (Common
NOTES Gateway Interface) specifications. Unless an application uses a proprietary Application
Programming Interface (API), it possibly uses the CGI because it is the standard way
of communication between a Web server and a custom application. CGI applications
can be written in almost any computer language, such as Perl and C.
By using the communication possibilities various computer languages, such as
using the sockets library which are available for all major platforms, the user can write
an application that converses with different servers and outputs the results in HTML
format. Thus the basic feature of multi-protocol applications based on the Web includes,
converse with other applications, use the information provided by them and then present
the results in HTML format. The key advantage of using CGI applications is that the
users have not to build a version for every known platform, because the program is
executed in the server-side and also because the output is in standard HTML, plain
text, etc., format. Hence, CGI is the only best alternative for creating multi-platform
applications.
WebPOP
The use of an integrated application with multiple protocols is based on a CGI program
termed as WebPOP, where POP stands for Post Office Protocol which is the most
common Internet protocol for retrieving mailbox contents. WebPOP is a very simple
WebPOP: Common Internet
protocol for retrieving mail reading program that accepts user input to present results formatted in HTML so
mailbox contents that the user’s browser can display it appropriately without any error.
WebPOP was specifically created to fulfill the requirements of the Internet users
in an easy-to-use mail programs. Internet and the World Wide Web (WWW) are
drawing attention of a lot of new users including the computer experts and also those
which are not computer literate. These users require a very simple mail program that
they can use for processing a mail messages every day. Using the standard Web
browser along with WebPOP on the server-side does not require a special purpose or
platform-dependent mail reader. On the client side, the only software required is a
common Web browser. On the server side, the Web server must comply with the CGI
specification as all the Web servers do.
WebPOP is a CGI application written in Perl (version 4.036) language which is
a very useful scripting language and is specifically used for developing CGI. An entity
is a program executing a particular function and is independent from other software
components on the system. There are five entities that support in the functioning of the
application, such as the CGI application (WebPOP), the user’s Web browser, the
Web server, the POP3 server and the SMTP server.
Technically, the word Web-based e-mail service specifies an e-mail service
offered through a Website, such as Gmail, Yahoo! Mail, Hotmail and AOL Mail.
Basically every Webmail provider offers e-mail access using a Webmail client and
many of them also offer e-mail access through a desktop e-mail client using standard
e-mail protocols.
Of the various applications of TCP/IP the most important one is the
internetworking equivalent of the real-world postal delivery system, commonly called
222 Self-Instructional Material
electronic mail or e-mail. The history of e-mail goes back to the very earliest days of ActiveX Controls
TCP/IP’s development. Today millions of people every day send both simple and
complex messages around the world through e-mail. TCP/IP e-mail is not any one
application. It is implemented as a complete system comprising several protocols,
software elements and components. All these elements perform one or the other part NOTES
of the complete communication process of e-mail. These include a standard message
format, a specific syntax for recipient addressing, and protocols to both deliver mail
and allow access to mailboxes from intermittently connected TCP/IP clients.
5.7.1 Mail Communication Process Steps
The modern TCP/IP e-mail communication process consists of the following five basic
steps.
1. Mail Composition
E-mail journey begins with the creation of a message, that is, electronic mail message.
There are two parts of a message: the header and the body. the header contains data
that describes the message and controls how it is delivered and processed, the body
of the message is the actual information that is to be communicated. The message must
be created as per the standard message format for the e-mail system so that it can be
processed. It must also specify the e-mail addresses of the intended recipients for the
message.
By way of analogy to real mail, the body of the message is like a letter, and the
header is like the envelope into which the letter is placed.
2. Mail Submission
There are various other internetworking applications besides e-mail. But, electronic
mail is different from many other internetworking applications in that the sender and
receiver of a message do not necessarily need to be connected to the network
simultaneously, nor even continuously, to use it. The system is so designed that after
composing the message, the user decides when to submit the message to the electronic
mail system so it can be delivered. The mail is transferred by using the Simple Mail
Transfer Protocol (SMTP).
This is analogous to dropping off an envelope at the post office, or to a postal
worker picking up an envelope from a mailbox and carrying it to the local post office
to insert into the mail delivery stream.
3. Mail Delivery
Once the user has submitted the electronic mail message, it is accepted by the sender’s
local SMTP system for delivery through the mail system to the destination user. Today,
this is accomplished by performing a Domain Name System (DNS) lookup of the
intended recipient’s host system and establishing an SMTP connection with that system.
SMTP also supports the ability to specify a sequence of SMTP servers through which
a message must be passed to reach the desired destination. One way or the other,
eventually the message arrives at the recipient’s local SMTP system.
This is like the transportation of the envelope through the postal system’s internal
‘internetwork’ of trucks, airplanes and other equipment to the intended recipient’s
local post office.
Self-Instructional Material 223
ActiveX Controls 4. Mail Receipt and Processing
Now, the local SMTP server accepts the e-mail message for further processing. It
places the mail into the intended recipient’s mail box, where it waits for the user to
NOTES retrieve it.
In our physical analogy, this is the step where the recipient’s local post office
sorts mail coming in from the postal delivery system and puts the mail into individual
post office boxes or bins for delivery.
5. Mail Access and Retrieval
The intended recipient periodically checks with its local SMTP server to see if there is
any mail for him/her. If so, the recipient can retrieve the mail, open it and read its
content. This is done by a special mail access protocol or method and not by SMTP.
The access protocol and client e-mail software may allow the user to scan the headers
of received mail (such as the subject and sender’s identity) to decide which mail
messages to download. This saves quite a lot of time as user need not actually open up
every mail.
This is the step where mail is physically picked up at the post office or delivered
to the home.
5.7.2 Electronic Mail Message Communication Model, Devices
and Protocol Roles
One of the critical requirements of an electronic mail system is that the sender and
receiver of a message need not be online at the time when mail is sent. TCP/IP therefore
uses a communication model with several devices that allow the sender and recipient
to be decoupled. The sender’s client device spools mail and moves it to the sender’s
local SMTP server when it is ready for transmission. The e-mail is then transmitted to
the receiver’s SMTP server using SMTP where it remains for an indefinite period of
time. When the recipient is ready to read it, he or she retrieves it using one or more of
a set of mail access protocols and methods, the two most popular of which are POP
and IMAP (see Figure 5.47).
[email protected]
[email protected]
abc
efg
efg
abc
MIME defines five headers that can be added to the original e-mail header section to
define the transformation parameters (see Figure 5.52).
1. MIME-Version
Each MIME message is required to have a MIME-Version header, which serves two
purposes. First, it identifies the e-mail message as being MIME-encoded. Second,
even though only one version of MIME has been defined so far, having a version
Self-Instructional Material 227
ActiveX Controls number header provides “future-proofing” in case a new version is created later that
may have some incompatibilities with the present one. Right now, all MIME messages
use version 1.0. This is the only MIME header that applies only to an entire message,
that is, it is not used to label individual MIME body parts, and is easy to remember as
NOTES it is the only header whose name does not begin with ‘Content-’.
2. Content-Type
Content-Type describes the nature of the data that is encoded in the MIME entity.
This header specifies a content type and a content subtype, which are separated by a
slash character.
Content-type: <type/subtype;parameters>
It may optionally also contain certain parameters that convey additional
information about the type and subtype. In a message body, this header is what tells
the recipient of the e-mail message what sort of media it contains, and whether the
body uses a simple or complex structure. In a body part, it describes the media type
the body part contains.
For example, a message containing an HTML document might have a Content-
Type header of ‘text/html’, where a message containing a JPEG graphical file might be
specified as ‘image/jpeg’. For a composite MIME type, the Content-Type header of
the whole message will contain something like ‘multipart/mixed’ or ‘multipart/alternative’,
and each body part will contain individual Content-Type headers such as ‘text/html’
or ‘image/jpeg’.
Table 5.5 Data Types and Subtypes in MIME
3. Content-Transfer-Encoding
For a message using simple structure, content-transfer-encoding specifies the specific
method that was used to encode the data in the message body; for a composite message,
228 Self-Instructional Material it identifies the encoding method for each MIME body part. For data that is already in
ASCII form, no special encoding is needed, but other types of data must be converted ActiveX Controls
to ASCII for transmission. This header tells the recipient how to decode the data back
into its normal representation.
Content-transfer-encoding: <type> NOTES
Table 5.6 Content-Transfer-Encoding
This header is optional; the default value if it is not present is ‘7 bit’ encoding, which
again is the encoding of regular ASCII.
4. Content-ID
Content-ID allows to assign a special identification code to the MIME content. This
header is analogous to the RFC 822 Message-ID header field, but is specific to the
MIME content itself. It is optional, and is most often used for body parts in multipart
MIME messages.
5. Content-Description
Content-description is an optional header that allows an arbitrary additional text
description to be associated with the MIME entity. In a multipart message, each body
part might be given a description header to make clear to the recipient what the parts
Content-ID: Allows to
represent. assign a special
MIME supports two basic overall formats: simple structure, in which a single identification code to the
type of discrete media is encoded in a message; and complex structure, which encodes MIME content
a composite media type that can carry multiple types of information.
5.7.6 Simple Mail Transfer Protocol
The most important component of the TCP/IP electronic mail system is the Simple
Mail Transfer Protocol (SMTP). Derived from Mail Transfer Protocol (MTP), SMTP
is the mechanism used for the delivery of mail between TCP/IP systems and users.
The only part of the e-mail system for which SMTP is not used is the final retrieval step
by an e-mail recipient.
In the early days of SMTP, mail was delivered using the relatively inefficient
process of relaying from server to server across the internetwork. Today, when an
SMTP server has mail to deliver to a user, it determines the server that handles the
user’s mail using the Domain Name System (DNS) and sends the mail to that server
directly.
NOTES
NOTES
[email protected]
abc
efg
efg
abc
NOTES
SMTP Responses
Each time the SMTP sender issues a command, it receives a reply from the SMTP
receiver (see Table 5.8). These replies are similar to FTP replies, and uses both a
three-digit reply code and a descriptive text line. A special enhanced status codes
SMTP extension is also defined; when enabled, this causes the SMTP receiver to
return more detailed result information after processing a command.
Table 5.8 SMTP Responses
NOTES
uses a component’s code by creating objects and calling their properties and
methods is referred to as a client.
• Properties for a class can be created by adding public variables and property NOTES
procedures to the class module. We can also create methods for a class by
adding public sub and public function procedures to the class module.
• Creating an ActiveX control is a relatively simple task in Visual Basic. For the
most part, the procedure is the same as creating a standard Visual Basic
executable.
• The UserControl Designer window displays the default project name
(Project1) and control name (UserControl1) in its title bar. This will change
once we assign meaningful names to the project and control.
• To test an ActiveX control, you need a separate Visual Basic project with a
form on which you can place an instance of the control. Rather than starting a
separate copy of Visual Basic, you can use one of Visual Basic’s easiest features.
• When you place an ActiveX control on a Visual Basic form during program
design, an instance of the control is created in memory.
• The property page interacts with the control it is attached to by using events.
Whenever a property page is opened, it receives a SelectionChanged
event.
• Once you have compiled the ActiveX control into an OCX file and removed
the ActiveX project from the project group, Visual Basic will automatically
switch to using the compiled version in the test project.
• A Custom control is an extension of the VB toolbox. A custom control file
is a special form of a Dynamic Link Library (DLL) file that contains one or
more types of controls.
• ImageList controls are invisible controls that serve one purpose, i.e., to
hold images that are used by other controls.
• To use the images in the image list, you usually associate the image list with a
Windows common control (which has an ImageList property).
• Status bars appear at the bottom of windows and usually hold several panels in
which you can display text.
• The status bar is there to give feedback to the user on program operation as
well as other items like the time of the day or key states (such as the Caps Lock
or the Ins key).
• Progress bars give the user some visual feedback on what is happening during
a time consuming operation.
• VDOLive is a quite latest technology developed for supporting the broadcasting
of both audio and video over the Internet or intranet.
1. An ActiveX DLL is an in-process server. The DLL is loaded in the same address
space as the client executable that calls the server and it runs on the same thread
as the client. At any given moment however, the client application or the DLL
keeps running. The merit of DLL is that it is faster, as in effect, it becomes a part
of the application that uses it.
2. An ActiveX EXE, otherwise called out-of-process server, runs as a separate
process. When a client application creates an object provided by an EXE server
for the first time, the server starts running as a separate process. If another client
application creates the same object, the running EXE server provides this object.
In other words, a single EXE server can service multiple clients. Out-of-process
238 Self-Instructional Material
servers seem to be more efficient in terms of resource allocation, but exchanging ActiveX Controls
by the recipient.
12. Content-Type describes the nature of the data that is encoded in the MIME
entity. This header specifies a content type and a content subtype, which are NOTES
separated by a slash character.
13. In the last few years a new method has been developed to allow e-mail access
using the World Wide Web (WWW). This technique is growing in popularity
rapidly, because it provides many of the benefits of direct server access, such
as the ability to receive e-mail anywhere around the world, while being much
simpler and easier than the older methods of direct access such as making a
Telnet connection to a server. WWW-based e-mail can in some cases be used
in combination with other methods or protocols, such as POP3, giving users
great flexibility in how they read their mail.
14. (a) VDOLive, (b) Scaleable, (c) Client-server, (d) Netscape Plug-in Application
Programming Interface (NPAPI).
15. (a) True, (b) False, (c) True, (d) True.
Short-Answer Questions
1. State the similarities and differences between DLL and EXE.
2. What is an in-process server? How does it differ from an out-of-process server?
3. List the steps involved in developing an ActiveX EXE.
4. What is instantiating? Is it used in ActiveX EXE or DLL?
5. What are the uses of ActiveX components? Mention the areas in which it is
used.
6. What is ActiveX control? What are the advantages and disadvantages of using
an ActiveX control?
7. What are the steps to be followed for testing an ActiveX control?
8. Discuss the different types of ActiveX controls.
9. What are custom controls? Are ActiveX controls and custom controls the
same?
10. Define TreeView, ListView and ImageList controls.
11. What is the significant of the PropertyBag object?
12. Identify and list the standard controls in Visual Basic.
Long-Answer Questions
1. Develop an ActiveX DLL which calculates the train fare for the following trains:
(i) Chenab Express
(ii) Himalayan Queen
Self-Instructional Material 241
ActiveX Controls (iii) Shatabdi Express
(iv) Bombay Mail
2. Explain the difference between Standard EXE and ActiveX EXE. What are the
NOTES types of ActiveX components used in VB?
3. What are the steps that are to be followed for testing an ActiveX control?
Explain each step with an example.
4. In what ways can an ActiveX control can be included in a project?
5. Create a user-drawn control that displays a ‘star’ button. Use method line to
draw the button.
6. Write an ‘enhanced’ TextBox control that only accepts numeric input.
7. Discuss how an ActiveX control differs from a standard control.
8. Explain the various ActiveX controls with the help of a program to create a
project.
9. Discuss the significance of VDOLive.
10. Explain the significant features of MIME, Web mail and IMAP
6.0 INTRODUCTION
In this unit, you will learn about Web graphics, i.e., the various graphical applications
used in Web page and Website design to give it attractive look. The computer graphics
refers to the process of creating, storing and manipulating the pictures, images and
drawings with the help of application software using a digital computer. With
developments in computing technology, computer graphics has become an effective
tool for the presentation of information in various fields including business, engineering,
art, entertainment, multimedia applications, education and training. The computer
generated pictures set twips, pixels and color settings for better image resolution and
effective graphic presentation. You will also learn to create line, circle, box and ellipse
drawings in Visual Basic for a Web page. The line control is used to draw lines on a
form at design time. An ellipse refers to a closed continuous line whose points are
positioned such that two points which are exactly opposite to each other have exactly
the same distance from a central point.
In this unit, you will also learn about the basics of Web page and Web design.
You will be acquainted with basic features of Web page, factors in creating and launching
a Website, creation of home page, navigation theory in Web designing, layout of
Websites, various types of Websites and architecture of Website. The Web or World
Wide Web (WWW) is fundamentally an assortment of an unlimited number of pages
(Web pages)/documents of information that are displayed on the Internet. It is
considered as information sharing tool. A Website is a set of Web pages related to
each other containing content, such as text, images, video, audio, etc. Finally, you will
learn about animation. Animation in computing field refers to a process used for setting
the illusion of movement where each drawing differs slightly from the earlier. The text
is explained with the help of illustrations.
World Wide Web (WWW) represents the network of Internetworking resources and
collection of Internet sites. WWW is known as Web started in computer world in year
1989 at CERN (European Council for Nuclear Research). Web includes Web pages
that are basically linked documents. These pages can be accessed across the network.
When one page is linked to other, it is considered as hypertext. The word ‘hypertext’
was invented by Vannevar Bush in the year 1945. Getting a Web page is possible
through Web browser. Many Web page editors are used to publish the Web pages,
for example, Dreamweaver, ColdFusion, FrontPage, GoLive, etc. These editors are
popularly used to design the Web page. Browser is the software that enables Web
page to be viewed by clients. WWW or Web is a global information medium which
users can read and write via computers connected to the Internet.
A Web page is an electronic document uniquely written in HTML (HyperText
Markup Language). Web pages can include text, graphics, video, animation, sound
and interactive elements, such as data entry forms. Web pages also include hyperlinks
to other Web pages. A Website contains one or more Web pages that share to a
common theme, such as a person, business, organization or a subject. The first page
of the Website is called the home page, which is an index of the content available on
the Website. The World Wide Web, also known as Web or WWW or W3, has
established itself as the most popular feature of the Internet. It is an incredible source
of information. Once you start searching anything ranging from documents to pictures
to software, it almost appears limitless. It provides you with documents, sound files,
view images, animation, and video, speak and hear voice, and view programs that run
on practically any software in the world. Therefore, it facilitates the rich and diverse
communication by enabling you to access and interact with text, graphics, animation,
photos, audio and video.
Technically, the Web graphics is the methodology how to create dynamic
graphics for the Website. Creating Web graphics is very easy. You can create desired
244 Self-Instructional Material
Web graphics or images in Visual Basic or Adobe Photoshop and can upload it to a Web Graphics
Web server on the Internet. The terms image and Web graphic are often used
interchangeably. Once a Web graphic or image is created and uploaded to a Web
server on the Internet, it can be linked using HTML or CSS. The following are some
examples of Web graphics: NOTES
• Logos are most commonly used in Web graphics. Most Websites have a logo
on every Web page. Logos are generally created using illustration software,
such as Adobe Illustrator and then exported to GIF (Graphics Interchange
Format) for uploading.
• Photos are also popular and are frequently uploaded as Web graphics which
are captured using digital cameras and mobile camera phones. Photos are either
scanned into the computer or imported directly from a digital camera. Once the
photo is saved on the computer, make required adjustments in format or color,
re-size it and then save it in JPEG (Joint Photographic Experts Group) format
for uploading.
• Icons help a Website look more professional and also help users in fast identifying
the purpose of a link. Basically, icons are created using illustration software,
such as Adobe Illustrator and then exported to GIF format for uploading.
• Decorative images are also sometimes used to create the image bits that HTML
and CSS can not create, for example, diagonal lines and rounded corners.
Decorative images are also used for repeating backgrounds on Web pages.
Depending on the image type, a decorative graphic can be created using
illustration software, such as Adobe Illustrator or image editing software, such
as Adobe Photoshop, Visual Basic or GIMP (GNU Image Manipulation
Program) and then it is exported to GIF format for uploading.
Computer graphics refers to the creation, storage and manipulation of pictures
and drawings using a digital computer. With developments in computing technology,
interactive computer graphics has become an effective tool for presentation of information
Computer graphics: It refers
in diverse fields, such as science, engineering, medicine, business, industry, government, to the creation, storage and
art, entertainment, advertising, education and training. There is virtually no field in manipulation of pictures and
which graphical displays cannot be used to some advantage and that is the basic drawings using a digital
computer
reason why application of computer graphics is so widespread.
It is a fact that one picture is worth a thousand words. So quite naturally interfaces
empowered with graphics enhances the communication between the computer and its
users. Representation of a huge set of numbers in the form of a graph or a picture helps
in better understanding and interpretation of the characteristics or pattern of the data
contained in the set of numbers. Graphical display helps to improve understanding of
complex systems and visualization of Two-Dimensional (2-D) and Three-Dimensional
(3-D) objects.
A major application of computer graphics is designing, particularly engineering
and architectural systems. Almost all consumer products are now computer designed.
Computer Aided Design (CAD) techniques are now extensively used in the design of
building, automobile, aircraft, watercraft, spacecraft, defense mechanism, computer
component, industrial machinery and device, textile and increasing number of other
products ranging from a pen to a refrigerator. In computer aided design environment,
traditional tools of design are replaced by parameterized modeling routines with Self-Instructional Material 245
Web Graphics interactive graphic capabilities so active and dynamic that the designer can carry out
unlimited number of experiments involving complex computation in search for better
design. Powerful digital graphic tools for molecular modeling have added a new
dimension in the research of emerging fields like biotechnology and bioinformatics.
NOTES
The applications of computer graphics, such as image processing, animation,
morphing, simulation, e-learning, material designing and graphic designing are rapidly
gaining demand and usage in education, training, advertisement and entertainment.
Computer graphics has highly influenced the film industry with its multimedia applications.
Controlled animation, simulation and morphing have increasingly been applied in the
study of time varying physical phenomena, object movement and operating sequences
of machinery in scientific and industrial research. Computer aided image processing
and picture analysis are now indispensable tools for remote sensing, aerial survey,
space research, pattern recognition, CT scans and research in medical science.
Computer graphics and animations can be created using Visual Basic. In Visual
Basic 6.0, the default unit of measurement is known as twips. One twip represents
1/1440 inch or 17.639 µm. Twips represent screen independent units which ensure
that the proportion of screen elements is arranged as the same on all the display systems
and devices. But, a pixel is a screen dependent unit which refers to a ‘picture element’.
A pixel is, in fact, a dot which represents the smallest graphical measurement on a
screen. Graphics are the visual presentations of real life objects. Some of the examples
include photographs, drawings, line art, graphs, diagrams, typography, numbers,
symbols, geometric designs, maps, engineering drawings and other images. Graphics
combine text, illustration and color along with features. The graphics which are created
by a computer is known as computer graphics. These graphics can be created using
the representation and manipulation of image data by a computer with the help of
specialized software and hardware. In these days, the computer graphics is used in
almost all the fields of education and news media. Computer images and graphics are
displayed on television and in newspapers, for example in weather reports, business
trends, etc. A graph presents the complex statistics in a form which is easy to understand
and interpret.
6.2.1 Web Graphics
Web graphics in any Websites is as significant as the content of the site. An exceptional
designed graphics can present enhanced and creative ideas to the Website visitors.
The Websites that do not have Web graphics can hardly appeal to visitors. Successes
of Web graphics depend upon the efficient and well-organized positioning on the
Websites. There is no limit in the Web specifications to the graphical formats that can
be used on the Web. The following are some specific formats that can be used to store
graphics.
• Portable Network Graphics (PNG).
• Joint Photographic Experts Group (JPEG).
• Graphics Interchange Format (GIF).
• Scalable Vector Graphics (SVG).
The software, such as Photoshop, Flash, Dreamweaver and Fireworks can be
used for designing and creating unique graphics. Usually, graphics are used for explaining
things and ideas that are not expressed easily by words, for example shopping and
e-commerce Websites. The following are the basics tips for creating Web graphics:
246 Self-Instructional Material
Clarity in Web Page: In a clear Web design the things should be placed Web Graphics
according to their importance so that the related things must look relevant with the
content.
Imagery: Image plays vital role in Web designing so it is advisable to try the
NOTES
level best to use an appropriate image for best impact on the visitors.
Color: Every color has its own language. Hence, color combination is also very
important aspects of Web designing. Without colors Web pages look dull and
unattractive. Using balanced color scheme Web pages can look attractive, dynamic
and inviting to users.
Readability: Font sizes used in Website plays vital role and work as great
differentiators. The font size depicts something important or a new section. It is suggested
to use sans-serif face for all body copy. Through using underlines, bold and italics
important things can be emphasized but use them in sparing fashion.
Effective Text: HTML text is used more often in Web designing. It is more
effective than the other graphic word. In the Web environment, text has enormous
strengths.
Page Layout: This refers to the way in which elements are arranged on screen.
So it is necessary to take great care while creating page layouts. The sequencing of
contents, graphics and images play important role in conveying messages regarding
Page Layout: This refers to
products and services.
the way in which elements
Alignment: Alignment helps to set text and graphics that should be directly, are arranged on screen.
clearly and easily visible on Web pages. Left-aligned text is easier to read than right-
aligned text. So, while Web designing it is suggested to follow Web alignment standard.
3D Effect on the Graphic Design: 3D effect creates space between different
text and elements.
Navigation Buttons: Navigation buttons help the visitors to navigate through
Website.
All these information are very important and must be followed during designing
Web graphic. All graphic images on your Website should match in color, typeface and
special effects.
The Role of Web Graphics
First and foremost, consistent interface and identity graphics across a collection of
Web pages define the boundaries of a ‘Website’. Site defining identity graphics do not
need to be elaborate, but they do need to be consistent across the range of pages in a
Website. The following are the various significant elements in Web graphics that serve
a number of purposes as elements of content along with and complementary to text
content:
• Illustrations: Graphics can illustrate things as per your requirements into the
document.
• Diagrams: Quantitative graphics and process diagrams can explain concepts
visually.
• Quantitative Data: Numeric charts can help explain financial, scientific or
other data.
• Analysis: Graphics help in easily analysing and interpreting data.
Self-Instructional Material 247
Web Graphics • Integration: Graphics can combine words, numbers and images in a
comprehensive explanation.
In any document, photographs and illustrations can be concisely designed so
that unnecessary explanation can be avoided and hence it saving ‘thousand words’ of
NOTES
explanation. Multifaceted information graphics often integrate quantitative charts, 3-D
illustrations, etc., for explaining complex concepts and natural phenomena.
Web Graphics Basics
The following are some significant and essential elements that must be considered
while creating Web graphics.
Pixels: Computer based images are comprised of thousands of tiny dots of
color called pixels. These are the small dots you see if you put your face too close to
your television or computer screen. Each digital image is comprised of thousands or
millions of individual pixels, each with its own color. When these groups of pixels are
viewed as a whole, we see the entire image. Most computer monitors have display
sizes of 800 × 600 pixels, 1024 × 768 pixels or 1280 × 1024 pixels.
Resolution: Resolution indicates the number of pixels that are displayed per
inch for an image (or pixels per centimeter). Most computer monitors display at
resolutions of 72 pixels per inch or 96 pixels per inch. If an image is 72 pixels wide,
Resolution: Resolution
indicates the number of then it will display as 1 inch big on a monitor that is set to a resolution of 72 pixels/inch.
pixels that are displayed per It is important to remember that for computer graphics, a higher resolution (pixels/
inch for an image (or pixels inch) does not mean a higher quality image. What is important is the total size in pixels
per centimeter)
of the image. Graphics for print and graphics for display on computer monitors use
different resolutions. In the images for print, a higher resolution will yield a higher
quality image.
Graphics and File Size: While crating Web graphic the image quality and file
size must be considered. Generally, the higher the quality of the image, the greater the
file size will be. Also, the larger the image, the larger the file size will be. It is important
to consider the file size of images when using them on a Web page. Images with large
file sizes take longer to load which can be an annoyance to the visitor.
Essay Web Graphics
Planning essays with a clear and coherent paragraph structure and flow is a challenging
skill. Providing visual ways of constructing and representing an essay structure can be
very helpful to many students, particularly those who are visual learners.
The essay Web is a graphic depiction (see Figure 6.1) of a structure for an
essay. The Web design is used to show how each paragraph is connected to each
other paragraph and how each paragraph is connected to the overall contention. The
circular movement may provide an alternative concept to the usual common procedure
of a linear set of steps and help students see how the essay has unity.
Russell Kealey describes a two stage process for essays where several filmic
devices are compared across three different films. Firstly students complete a three
set Venn diagram to help identify which filmic devices are present strongly in all three
films. This thinking helps the students populate an electronic essay plan set up in Publisher
with movable text boxes. In each text box, the students enter dot points about how
(say) filmic device A is used in film B. Further text boxes call for introductory, linking
248 Self-Instructional Material
and concluding sentences and then the whole set can be rearranged into a visual plan Web Graphics
for the essay.
Another advantage of these sorts of graphics is that they allow students to think
about one aspect of the essay plan without having to hold all the other aspects in their
NOTES
short term memory.
The WWW is a subset of the Internet and comprises of a huge collection of documents
stored in computers across the world. The Web encompasses special sites called
Websites along the Internet that support Web browsing. By clicking on the links that
appear on the Webpage, one can navigate from one place to another. Hence, Webpage
can be defined as a single hypertext document written in HyperText Markup Language
(HTML) and described in HTML basics. A Web page normally incorporates the
basic information and links to navigate in the Websites to which it belongs. Documents
in the World Wide Web are classified into three types, namely static, dynamic and
active documents.
Static Web Page
These are fixed content documents which perpetually provide the same information in
response to all download requests from all Web users. Static documents are stored in
a Web server to be accessed by the Web client. The Web client, on requesting for a
Web page gets a copy of the same. The contents of such files are not subject to
modification on part of the Web user as the Web user does not have right to alter
them. However, the Web pages can be modified in the server per say. Thus, the static
Web pages display the same information to all the Web users and provide hypertext
links to perform navigation through static documents. Their biggest advantage is that
they are cache friendly. This enables the Web pages to display one copy of the same
250 Self-Instructional Material
Web page to many people simultaneously. However, it becomes difficult to maintain Web Graphics
Web pages in case of large sites as they demand consistency and updation.
Dynamic Web Page
These Web pages provide interactive Web navigation and help modify the content like NOTES
text, images, form fields, etc., on a Web page, depending on different contexts or
conditions. The dynamic Web pages make use of two types of inter-activities, which
are enlisted as follows:
• Client Side Scripting: It is used to modify interface behaviours within a specific
Web page. This modification is based on the mouse or keyboard actions and is
conducted at specified time intervals. The dynamic behaviour takes place within
Client side scripting: It is
the presentation. The presentation technologies like JavaScript or ActionScript
used to modify interface
for Dynamic HTML (DHTML) and Flash for media types are used. The client behaviours within a specific
side scripting also facilitates the use of remote scripting in which the DHTML Web page
page requests for additional information from the server. The content is generated
on the Web client’s machine in which the Web browser retrieves a page from
the server and processes the code embedded in the Web page, so that the
contents of the retrieved page can be displayed to the Web user. Sometimes,
the Web browsers do not support the language and the commands of the scripting
language, in the client side dynamic pages.
• Server Side Scripting: It is used to modify the requested Web page source
amongst pages to either adjust the sequence or reload the Web pages delivered
to the browser. Server responses are based on certain conditions like data in a
posted HTML form, parameters in the URL, the type of browser being used,
the passage of time or a database or server state. Server side scripting dynamic
Web pages are designed with the help of server side languages like PHP, Perl,
ASP, JSP, etc.
Both the techniques may be used simultaneously to develop the dynamic Web
pages. The advantages of dynamic Web pages are that these facilitate easy update of
the Web pages and faster Web page loading. In the dynamic Web pages, the content
and the design are located separately, thereby allowing frequent modifications to the
Web pages including the text and image updates.
Active Documents
The programs that run at the client side are known as the active documents. Whenever
a Web client requests for an active document, the Web server provides a copy of the
same in the form of byte code. The document is now ready to be run at the Web client
machine. As the active document is served in the binary form, compression and
decompression can be applied at the server and the client side to reduce the bandwidth
requirement and throughput.
6.3.1 Web Design
Home page is known as the first page of the Web page. It is replete with a myriad of
hyperlinks on its page. Creation of a home page connotes creating and launching of
the Website. This is a consequential task which is accomplished by arranging the
Website hosting, designing and coding of the Website, monitoring the functioning of
the site and by scrutinizing the Website traffic. Creating the Website takes into
consideration, various factors which are to be implemented on the page. Launching
Self-Instructional Material 251
Web Graphics the Website is an important operation. This requires information pertaining to name,
phone, URL description as well as the domain details. It should be ensured that the
Website must be kept in the right direction. A comprehensive user’s guide that conveys
the relevant information of the Website must be provided to the user. This can be done
NOTES after successfully launching the Website. The more accurate the details are, the better
the results would be. The task of launching the Website can be carried out in the local
listing of Google and Yahoo. This optimizes the search engine facilities for your Website,
which offers moderate list of options, searchable information and the third party data
providers, such as SuperPages, YellowPages, CitySearches, etc. These search engines
provide a great facility to recite the name of your Website. Such search engines also
offer a free Jumpstart program in which you can enter you Website domain area, avail
the ‘WAY’ (Who You Are) facility, get reviews and list hours, etc. There are many
factors that determine the success of a Website on the Internet. The following factors
should be taken into consideration while creating and launching a Website:
• Message Board: It is a type of forum through which visitors of the Website
interact with the site to enhance its popularity.
Message board: It is a type
• Search Engine: This is a valuable retention tool which helps visitors to search
of forum through which relevant information, provided the site is enlisted with a famous search engine.
visitors of the Website • Polls: This option on the Website enables the visitors to vote as per their
interact with the site to
enhance its popularity
satisfaction. For instance, the users can assess the performance of the Web
services by giving their feedback with the help of the feedback option.
• Guestbooks: This Website facility helps the users contact the organization for
which the particular site is created. Through this facility, the Website visitors can
enter their name, e-mail, comments and suggestions. Once this information
reaches the organization, the respective executive of the organization contacts
the visitors.
• Data Entry Forms: Through this option, the Website visitors can place orders
and can also provide request information. Data entry forms also facilitate storing
of customer service data which is later entered into a computerized database or
spreadsheet by the organization.
Dynamic Websites
A Dynamic Website is one that changes or customizes itself frequently and
Dynamic Website: One that
automatically based on certain criteria. Dynamic Websites can have two types of changes or customizes itself
dynamic activities namely, code and content. Dynamic code is invisible or behind the frequently and automatically
scenes and dynamic content is visible or fully displayed. Figure 6.4 displays the layout based on certain criteria
of a dynamic Website.
Self-Instructional Material 255
Web Graphics
NOTES
In Website, keywords are the words which are used to surf the corresponding
information regarding Web page content. Keywords are important because it allows
your customers to find your Web page when they search the Internet. Bounce rates
can be used in determining the effectiveness or performance of an entry page of Website.
An entry page with a low bounce rate means that the page effectively causes visitors to
view more pages. Google Analytics is a free service offered by Google that generates
detailed statistics about the visitors to a Website. Google Sites is a free and easy way
to create and share Web pages.
The WWW was originally designed as a stateless entity. A client sends a request; a
server responds. In Figure 6.5, Registrar is the company of domain name. Web address,
such as ‘www.yourdomain.com’ hosting company represents the company where files,
data and information is kept for a specific Website (see Figure 6.5). Web designer
represents the development team who creates the Website (Web pages, scripts, page
layout and graphics) whereas the Internet (connecting all the Web servers across the
Internet).
NOTES
NOTES
The content and navigation are ensured suitable page footer in two ways, such as
using the styles in Cascading Style Sheets or CSS and tables. CSS is a style sheet
language used to describe the presentation semantics (the look and formatting) of a
document written in a markup language. The most common application is to style Web
pages written in HTML and XHTML but the language can also be applied to any kind
of eXtensible Markup Language or XML document, including plain XML, Scalable
Vector Graphics or SVG and XML User Interface Language or XUL. The CSS
ensures a suitable page header and below that navigation is set in the left side column
as shown above. A primary navigation must be always clear, structured and intuitive. It
holds at least 4 to 15 links in which group of 4 to 5 links are enclosed at a time along
with headings so that navigation bar perform fast tasks after scanning or clicking. The
secondary navigation keeps the common place links, such as Contact, About Us, Site
Map, Home and copyright information. Links between the pages of the Websites are
considered as certain way to tie the multiple pages together. Some of the features,
such as ‘Link Back to Your Homepage’ is always considered as essential link because
the home page is considered as central hub which is used to connect almost all the
navigational links, ‘breadcrumb trail’ shows frequently the row of links which represents
the how the Website is structured whereas ‘Page jumps’ represents the link of sections
in a single page. In ‘Page jumps’ format, a long page is maintained so that user can
reach easily to required bookmark. A ‘site map’ is also a significant mechanism which
links to all the pages to the Home page links.
Navigating the Web
Navigating the Web means moving from one Web page to other. Web page is designed
generally in that way in which whole information might come within a page. Generally
Web page is aligned on the left side. The purposes of navigating the Web are as
follows:
• It presents visitors along with most user friendly path so that they can get quick
information via requested page.
• It endures visitors to know the location of Website.
• It allows visitors to move quickly on logically arranged pages.
NOTES
• Real Estate Websites: These Websites help to sell the residential property or
several commercial office blocks.
• Non-Profit Websites: It is being offered on the Web server for all non-profit
organizations our Web design services at an incredible discount of approximately
30 or 40 per cent the normal rate. It could be a charity organization, a public
service group or a small business.
• Blog: A Website that is used to log online readings or to post online diaries may
include discussion forums or chat rooms. The Internet address has a variety of
endings. A blog is a type of Website or part of a Website supposed to be Blog It is a type of Website
updated with new content from time to time. Blogs are usually maintained by an or part of a Website
individual with regular entries of commentary, descriptions of events or other supposed to be updated
material, such as graphics or video. with new content from time
to time
Website Architecture
The layout and design framework of a Website and each of its pages describe collectively
to the Website architecture. The relationship between each page and the whole Website
as well as the relationship between each page and every other page is the primary
consideration when designing a Website from an architectural standpoint. How both
content and navigation are positioned on each of the pages is also an extremely important
consideration both for the end-users visiting the site and for search engine optimization.
It displays the building blocks and architecture of successful Website. The architecture
is divided into five layers which are Impact Layer, Surface layer, Persuasion Layer,
Value Creation Layer and Management Layer. In Impact layer, the key success
indicators are trust and credibility, branding and image, user experience, loyalty and
retention and conversion rates. Surface layer deals Home page, landing pages,
navigation layout and content information architecture. The features of successful Web
page, such as marketing and promotion personas, buying behaviours/motivations,
conversion funnels and persuasion strategies are designed in Persuasion layer. In Value
Self-Instructional Material 261
Web Graphics Creation layer, relationship building optimization strategies, pricing offer and positioning
competitive intelligence are designed whereas iterative management, tracking and
measuring unique value proposition, strategic purposing goals and objectives are
designed in Management layer. Site identify, branding, content layout and design, eye
NOTES catching presentation of Websites are designed in two layers, such as Surface layer
and Persuasion layer .
In order to draw the primitive objects, one has to first scan convert the objects. This
refers to the operation of finding out the location of pixels to be intensified and then
setting the values of corresponding bits, in the graphics memory, to the desired intensity
code. Each pixel on the display surface has a finite size depending on the screen
Check Your Progress resolution and hence a pixel cannot represent a single mathematical point. However,
1. Name the major application we consider each pixel as a unit square area identified by the coordinate of its lower
of computer graphics. left corner, the origin of the reference coordinate system being located at the lower
2. What does ‘twips’ left corner of the display surface. Thus each pixel is accessed by a non-negative integer
represent?
coordinate pair (X, Y). The X values start at the origin and increase from left to right
3. Define the term pixel.
along a scan line and the Y values (i.e., the scan line numbers) start at bottom and
4. What are dots?
increase upwards.
5. What is aspect ratio?
6. Why the ClipControls Line drawing is accomplished by calculating intermediate point coordinates along
property is used? the line path between two given end points. Since screen pixels are referred with
7. How line drawing is integer values, plotted positions may only approximate the calculated coordinates,
accomplished? i.e., pixels which are intensified are those which lie very close to the line path if not
264 Self-Instructional Material
exactly on the line path, which is in the case of perfectly horizontal, vertical or 45° lines Web Graphics
only. Standard algorithms are available to determine which pixels provide the best
approximation to the desired line. Still, screen resolution is a big factor towards improving
the approximation. In a high resolution system the adjacent pixels are so closely spaced
that the approximated line pixels lie very close to the actual line path and hence the NOTES
plotted lines appear to be much smoother almost like straight lines drawn on paper. In
a low resolution system, the same approximation technique causes lines to be displayed
with a “stair step appearance” (refer Figure 6.8(a)).
Following is the list of objects used in Visual Basic for graphical representation:
• Graphics Object: Provides methods for drawing a variety of lines and shapes.
These methods provide various properties for making simple or complex shapes
in solid or transparent visibility, allows filling of content with a range of colors
using user defined gradient or image textures.
• Pen Object: To draw lines and curves.
• Brush Object: To fill in a closed area with some color or texture.
Table 6.2 summarizes the list of colors and their constants which can be used in
Visual Basic code.
Table 6.2 List of Colors Constants
vbGreen
vbBlue
vbCyan
vbMagenta
vbYellow
vbBlack
vbWhite
To Draw a Circle
In Visual Basic, drawing circle specifies the circle’s centre and its radius. Following
Visual Basic code is written to draw a circle with a radius of 1000 twips in the upper
left corner of the form:
Circle (1200, 1200), 1000
In Visual Basic, the Circle method uses the current values of the
DrawWidth, DrawStyle, FillStyle and FillColor properties which
collectively draw the circles with thick borders and can also fill them with a pattern.
The circle’s border is drawn using the current ForeColor value but you can
override it by passing a fourth argument as defined in Circle method:
‘ A circle with a 3-pixel wide red border
‘ Filled with green solid color
DrawWidth = 3
FillStyle = vbFSSolid
FillColor = vbGreen
Circle (1200, 1200), 1000, vbRed
Above code draws a circle 3-pixel wide red border and filled with green solid
color:
To draw an ellipse, use the Circle statement. It takes two arguments that determine
the shape of the ellipse, namely the radius and he aspect ratio. The aspect ratio
represents the number and can be calculat ed when you divide t he
NOTES
Y-radius by the X-radius of the ellipse.
To draw an ellipse using Pen object, the code is written as follows:
Dim redPen As New Drawing.Pen(Color.Red, 10)
e.Graphics.DrawEllipse(redPen, 10, 10, 100, 200)
Above code draws an ellipse using a width of 10 pixels as follows:
To Draw a Rectangle
To draw a rectangle, the code is written as follows:
Dim redPen As New Drawing.Pen(Color.Red, 10)
e.Graphics.DrawRectangle(redPen, 10, 10, 100, 200)
Above code draws a rectangle using a width of 10 pixels as follows:
To Draw a Box
A box is drawn in Visual Basic using the same snytax as drawing a rectangle. The
Paint event subroutine is provided by an interface of the coding Editor. For this,
you need to create a paint brush with which you paint using the following set of statements:
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs)
Handles Me.Paint
Dim redBrush As New Drawing.SolidBrush(Color.Red)
End Sub
In the above code, SolidBrush drawing object is created using color Red
and assigned it to variable redBrush. Then, the brush is used to draw a shape:
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs)
Handles Me.Paint
Self-Instructional Material 267
Web Graphics Dim redBrush As New Drawing.SolidBrush(Color.Red)
e.Graphics.FillRectangle(redBrush, 20, 30, 100, 100)
End Sub
The above example uses the Graphics object to draw a rectangle at
NOTES coordinates X=20, Y=30 of height and width equal to 100 for each. Press F5 function
key to build and run the application which appears as follows:
Visual Basic supports various brush effects, such as gradient effect. The gradient
effect is achieved using the LinearGradientBrush method which is written
as follows:
Dim myRectangle As New Drawing.Rectangle(10, 10, 100, 100)
Dim myGradient As New Drawing2D.LinearGradientBrush
(myRectangle, Color.Red, Color.Blue, 50)
e.Graphics.FillRectangle(myGradient, 20, 30, 100, 100)
The above code produces the following output:
A computer animation sequence can be set up by specifying the storyboard, the object
definitions and the image frames. The storyboard is an outline of action. It consist of
rough sketches of motion sequence or it could be a list of basic events that take place.
Object definitions are given for each participating object in terms of their shape and NOTES
movement. The still image frames are either drawn manually or computer generated to
simulate motion sequence of animating objects. The illusion of movement is created by
playing 15-20 numbers of such still images with small changes made to each one per
second. The eyes retain an image long enough to allow the brain to connect the frames
in an uninterrupted sequence. In traditional animation, as many as 30 FPS (Frames
Per Second) might be used to give a smoother appearance at high speeds.
Animation Techniques in Visual Basic
Animation is an interesting and exciting part of programming. Even though VB is not
specifically designed to handle advance animations still some simple interesting animated
effects can be created. The simplest way to create animation is to set the Visible
Property of a group of images or pictures or texts and labels to True or False by
triggering a set of events, such as clicking a button.
Example
The following is a VB program that creates the illusion of moving the plane in four
directions, i.e., North, South, East and West. To do this animation, first insert five
images of the same picture of plane into the VB Form. Set the Visible property of the
image in the center to be True while the rest set to False. On start up, a user will
only be able to observe the image in the center. Next, insert four command buttons
into the Form and change the Labels to Move North, Move East, Move West and
Move South, respectively. Double click on the Move North button and key in the
following procedure:
Sub Command1_click( )
Image1.Visible = False
Image3.Visible = True
Image2.Visible = False
Image4.Visible = False
Image5.Visible = False
End Sub
By clicking on the Move North button, only Image3 is displayed. This will give an
illusion that the plane has moved in North direction. Enter similar procedures by double
clicking other command buttons to complete the rest of the actions. You can also insert
an additional CommandButton and label it as Reset and then enter the following
codes:
Image1.Visible = True
Image3.Visible = False
Image2.Visible = False
Image4.Visible = False
Image5.Visible = False
Clicking on the Reset button will make the image in the center visible again while other
images become invisible, this will give the false impression that the plane has moved
back to the original position as shown in the following screenshot.
Self-Instructional Material 269
Web Graphics
NOTES
You can also issue the commands using a TextBox as illustrated below:
Private Sub Command1_Click()
If Text1.Text = “n” Then
Image1.Visible = False
Image3.Visible = True
Image2.Visible = False
Image4.Visible = False
Image5.Visible = False
ElseIf Text1.Text = “e” Then
Image1.Visible = False
Image4.Visible = True
Image2.Visible = False
Image3.Visible = False
Image5.Visible = False
ElseIf Text1.Text = “w” Then
Image1.Visible = False
Image3.Visible = False
Image2.Visible = False
Image4.Visible = False
Image5.Visible = True
ElseIf Text1.Text = “s” Then
Image1.Visible = False
Image3.Visible = False
Image2.Visible = True
Image4.Visible = False
Image5.Visible = False
End If
End Sub
Another simple way to simulate animation in VB6 is by using the Left and Top
properties of an object. Image.Left gives the distance of the image in twips from
the left border of the screen and Image.Top gives the distance of the image in
twips from the top border of the screen, where 1 twip is equivalent to 1/1440 inch.
Using a statement, such as Image.Left-100 will move the image 100 twips to
the left, Image.Left+100 will move the image 100 twips away from the left (or
100 twips to the right), Image.Top-100 will move the image 100 twips to the
top and Image.Top+100 will move the image 100 twips away from the top
270 Self-Instructional Material border (or 100 twips down).
6.5.1 Graphical CommandButton Web Graphics
To load a picture or image into an image box or a picture box, you can click on
the Picture property in the Properties Window and a dialog box will appear
which will prompt the user to select a certain picture file. You can also load a picture at
runtime by using the LoadPicture() method. The syntax is as follows:
Image1.Picture= LoadPicture(“C:\path name\picture file name”)
picture1.Picture= LoadPicture(“C:\path name\picture name”)
For example, the following statement will load the grape.gif picture into the
image box.
Image1.Picture= LoadPicture(“C:\My Folder\VB
program\Images\grape.gif”)
Self-Instructional Material 271
Web Graphics In the following example, each time you click on the ‘Change Pictures’
CommandButton, you will be able to see three images loaded into the image
boxes. This program uses the Rnd function to generate random integers and then
uses the LoadPicture() method to load different pictures into the image boxes
NOTES using the If…Then statements based on the random numbers generated. The output
is shown as follows:
and CSS can not create, for example, diagonal lines and rounded corners.
Decorative images are also used for repeating backgrounds on Web pages.
• Computer graphics refers to the creation, storage and manipulation of pictures NOTES
and drawings using a digital computer.
• In Visual Basic 6.0, the default unit of measurement is known as twips. One
twip represents 1/1440 inch or 17.639 µm. Twips represent screen independent
units which ensure that the proportion of screen elements is arranged as the
same on all the display systems and devices.
• In Visual Basic, the AutoRedraw property is used when the graphics methods
are called from an event other than the Paint event whereas the
ClipControls property is used to control the painting of a Form. When
the value is set to True, only exposed areas are repainted.
• The WWW is a subset of the Internet and comprises of a huge collection of
documents stored in computers across the world.
• The programs that run at the client-side are known as the active documents.
Whenever a Web client requests for an active document, the Web server provides
a copy of the same in the form of byte code.
• Home page is known as the first page of the Web page. It is replete with a
myriad of hyperlinks on its page.
• Launching the Website is an important operation. This requires information
pertaining to name, phone, URL description as well as the domain details. Launch
of the site is carried out after designing and completion of the site. It is essential
to finalize the layout and style of the site before launching. It is significant to note
that before the launch of the Website, its domain should be registered.
• A Website is launched with the help of File Transfer Protocol (FTP). It is an
economical option. The owner of Website must instruct the Web designer and
the system analysts to implement FTP before the launch of the Website.
• A Website is written in HTML and is a collection of linked Web pages on a
Web server which can be electronically accessed.
• A static Website is one that has Web pages stored on the server in the format
that is sent to a client Web browser. It is primarily coded in HTML.
• A dynamic Website is one that changes or customizes itself frequently and
automatically based on certain criteria. Dynamic Websites can have two types
of dynamic activities namely, code and content. Dynamic code is invisible or
behind the scenes and dynamic content is visible or fully displayed.
• Navigating the Web means moving from one Web page to other. Web page is
designed generally in that way in which whole information might come within a
page.
• The basic Web architecture is characterized by two-tiered services in which
Web client gets the information and Web server provides information to the
client.
Self-Instructional Material 275
Web Graphics • A Web hosting service refers to a type of Internet hosting service that allows
individuals and organizations to make their own Websites accessible via the
WWW.
NOTES
6.7 ANSWERS TO ‘CHECK YOUR PROGRESS’
Short-Answer Questions
1. What is Web graphic?
2. What is the significance of computer graphics?
3. What is the significance of dot pitch?
4. What does DrawMode property controls?
5. Why the Pen object is used?
6. Write the first required step to create an animation in Visual Basic.
7. How twips are used to measure distance of the image?
8. Why split buttons are used?
9. What is a Web page?
10. Define Website and its types.
Long-Answer Questions
1. Discuss the significance of Web graphics and its various types with the help of
examples.
2. Explain the usage and significance of computer graphics with the help of
examples.
3. Describe the various graphics properties and methods with the help of examples.
4. Explain the line, circle, box and ellipse drawing with the help of Visual Basic
syntax and coding.
5. Explain the various types of Web pages.
6. Summarize the factors that should be taken into consideration while creating
and launching a Website.
Self-Instructional Material 277
Web Graphics 7. Discuss Web hosting with the help of examples.
8. Explain the significance of animation in Visual Basic graphics.
9. Write a Visual Basic code for interface design which shows the effect of the bird
NOTES flapping its wing and flying at the same time.
10. Discuss the various usage patterns of CommandButton.
PART A (5 × 8 = 40 marks)
PART B (4 × 15 = 60 marks)