Web Programming 1
Web Programming 1
Domain Purpose
names
Com Commercial organization
Government organizations
edu Educational
institutes/organizations
International organization
Network group
org Non profit organization
Milftary group/organizations
wwwwwwwwwwwww
TECHNICAL PUBLICATIONS- An up thrust for
knowledge
Web Programming 1 - 5 Fundamentals and Introduction to XHTML
com 9ov
org edu
UK
in
ac
redif
yahoo gmail tec pub
cse ece it
Parth Anand Arun Anuradha
Fig. 1.1.1 Domain name space
Review Questions
1. Explain domain names with an example.
Question Bank, Marks 5
2. Define Internet.
Question Bank, Model Question Paper, Dec:-17, Mark 1
3. Define Internet. Explain briefly domain name.
May-12. Marks 5
1.2 www
World Wide Web (Www) is collections of software and
used to access the resources over the network. corresponding protocols
The world wide web is information system in which various documents
a
containing information are interlinked together. User can access this information
or write the information via
computers. This information is typically
stored on the
web pages and through web browsers we can access these web pages.
The web pages may contain the information in the form of
text, audio, video,
images and graphics. We can navigate between the web pages using hyperlinks.
1.2.1 Origins
The concept of WwW was introduced by Sir Tim Berners-Lee the
contractor at
the European Organization for Nuclear Research (CERN), Switzerland in
1980.
He built a personal database of people and software models and used
that each new page of information was linked to an existing page.
hypertext so
In 1990, Berners-Lee introduced the tools such as HyperText Transfer Protocol
(HTTP), HyperText Markup Language (HTML) and the web browser. This is the
time when the first website http://info.cern.ch/was built.
TECHNIC
4. Opera
5. Netscape Navigator
Review Question
e The web server and web client communicate with each other using HITP
protocol.
us When web server starts its execution, it informs operating system that it is now
sed ready to accept the requests on specific port.
Web client opens a network connection with web server and sends the request to
web server. The web serverlistens the web client requests on particular port.
The primary task of web server is to monitor communications on specific port,
two
accept HTTP command through that port and perform operations specified by
these commands.
nters, When the request from client is received by the server it is translated either in file
tions name or a program name. If it is a filename, then the requested file is transferred
er the
to the lient. And if it is a program name, then the program is executed and its
outputis given to the client.
other
1.4.2 General Server Characteristics
File structure
There are two types of directories for the server. The roots of these directories are
documentroot and server root. These directories and the subdirectories store the
arks 7 software required for server execution.
The files that are stored directly in the document root directory are available to the
rieving,
clients using the top-level URL. Normally the clients do not access the document
root directly.
Normally server stores the documents that are readable to its client outside the
document root.
TECHNICAL PUBLICATIONS An up thrust for knowledge
Web Programmin9 1-8 Fundamentals and Introduction to XHTM
The virtual document trees are the areas from which the server can serve t
the
documents to its clients.
If the documents are stored in the subdirectories then cient can refer to these weh
documents using the URL with a particular file path to that directory from
he
document root directory.
Some servers allow the access to the web documents that are in the document TOnt
of other machine. Such servers are called proxy servers.
Web servers support various protocols such as HTTP, FTP, Gopher, News and
mail.
All the web servers can interact with the database systems with the help of
Common Gateway Interface (CG) or server side script.
1:4.3 Apache
Itis an excellent server because of its two important features Reliability and
Efficiency.
Secondly it is more popular because it is an open source software. That means it is
freely available to anybody. Apache web server is best suitable for UNIX systems
but it can also be used on Windows box. The
apache web server can be configured
as per the
requirements using the file httpd.conf. This
file is present in the Apache
software package.
1.4.4 11Ss
T h e Internet Information Services orInternet Information Server is
web
akind of
server provided by Microsoft. This server is most
popular on Windows
platform.
Following are some differences between Apache and IS servers
Sr. Apache Web Server
1ISWeb Server
No.
Apache web server is useful on both
based systems and on Windows platform.
UnixIS web server is used on Windows platform
2 Itis an open source product
is a vendor specific product and can be used on
windows products only.
3 The Apache web server can be controlled by
For IS server the behaviour is
moditying the window based controlled
editing the configuration file htpd.con Dy
managernent
programs called HS snap in. We can accesS
Snap in through the Control-Panel- Administratve
Tools
Review Questions
1. Define web server.
Question Bank, May-14, Dec.-17, Mark 1
2. Explain the operation of web server.
Question Bank, May-13. Dec,-16. Marks 5
3. Illustrate the general server characteristics. Question Bank, Dec.-12, 16, Marks 5
4. Explain the file structure of wveb server. Question Bank,Marks 5
5. Explain the operation of web server with its file structure. Question Bank, Marks 10
1.5 Uniform Resource Locator Dec.-13, May-16, Marks 5
For identifying the documents on the internet the uniform or universal resource
Locator i.e. URL is used.
Scheme:Address
That is
protocol://username@hostname/path/filename
The scheme specifies the communication protocol. Different schemes have
different schemes have different forms of addresses.
Various schemes that are used are http, ftp, gopher, file, mailto, news and so on.
The most commonly used protocol for web browser and web server
communication is hypertext transfer protocol(HTTP). This protocol is based on
request-response mechanism. This protocol handles the documents that are
created using eXtensible Hypertext Markup Language (XHTML). Using http the
Address part of URL can be written as follows -
I/Domain_name/path to_Document 2
tder
file is another most commonly used scheme in URL. This protocol allows to reside hon
the document in the client's machine from which the web browser is making out
the demand. Due to this the actual document is not available only for its visibility
but it can be tested. Using file the Address part of URL can be written as follows-
file://path-to-document
The hostname is the name of the server computer that stores the web documents.
Content
http://www.mywebsite.com a2 text/htmi
This indicates that the file
mydocs/index.html is specified in the configuration file. inage/gif
Review Questions audio/mid
1. Discuss URL format with its application
different paths. Question Bank, Marks 5
2. Explain URL with general format. Example of MIM
Dec.- 13, May-16. Marks 5
HITP/1.0 200 Ox
1.6 Multipurpose Internet Mail Extension (MIME) Date: Thu, 14 Dec. 2016 0
Server: Apache/1.1.0
Nov.-11, May-12, 16, Marks Content-type: image/jpes
On the Internet, data is sent in the form of bytes. The Set-Cookie: Apache=loc
these bytes and arranges this data in the receiving software collec
proper order. But from these bytes Content-length: 32719
data it is not clear whether it is text ? Or whether Last-modified:Fri, 14 De
they represent a movie ? Then for a user at the they are picture ? Or whethe
a
Here note that thec
"How is it possible to know what the data is receiving end the question arise
addition to the bytes some additional few ?" On the other hand, suppose,
bytes are sent along with the actual dau
telling what the data is then the receiver will
1.6.2 Experimental
of data or message. This is what MIME easily come to know about the tyP Sometimes the
does!! It tells what is
the message contents can be used in an in a message so tn
The experimen
appropriate way.
Definition: Multipurpose Internet Mail Extensions The web prov.
specifies how messages must be formatted
(MIME) is an open standard. that particular
so that they can be
different e-mail systems. exchanged betwee
Contents-
For example The content of some image can be specified as Imageljpg. This means thee
bype of e-mail content is image and subtype is jpg image.
Example of MIME
HTTP/1.0 200 OK
Date: Thu,14Dec. 2016 00:04:30 GMT
Server: Apache/1.1.0
Content-type: image/jpeg
Set-Cookie: Apache=localhost349860630670983; path F/
Content-length: 32719
Last-modified: Fri, 14Dec 201618:45:59 GMT
Here note that the content type is image which is actually a jpeg image.
May-12, Marks 5
1.7 The Hypertext Transfer Protocol Nov.-11, Dec.-16, 17,Marks 5
Hyper Text Transfer Protocol (HTTP) takes part in web browser and web
communication. Hence it is called a communication
server
HTTP protocol is that it follows the
protocol. The basic feature
of
request
response model. The client
makes a
request for desired web page by giving the URL in the address bar. This
submitted to the web server and then web server request is
gives the response to the
browser by returning the web
required
web page.
1.7.1 HTTP Request Message Structure
The basic structure
of request message is given by following general form-
<Start line>
<Header fields>
<Blank Line>
<Message Body>
Let us discuss this structure in detail
<Start line>
The start line consists.of three parts which are separated a
by single space. These parts
are
This method supports for the specified URL. It can be used to check the
OPTION functionality of a web server by requestinginstead of a speciic
resource
Intended Server
URL
fp//ftp.mywebsite.com/index.bxt file can be located on FTP server
3. HTTP version : The first HTTP version was HTTP/0.9 but the official version of HITTP
was HTTP/1.1
GET /pub/WwW/HTTP/1.1-
Host:www.vtubooks.comm
accept:text.html,video/x-mng.image/png, image/jpeg
accept-language.en-us, en
Header Flelds
connection:keep-alive
keep-alive:500
content-length:10
hello world
Blank Line
Message body
Fig. 1.7.1 HTTP request message structure
www.wwwnwnivwnwwwwwwwawwerana
inyi
XHTML
Fundamentals and Introduction to
1-15
Web Programming
Message Structure
1.7.2 HTTP Response message
structure. It is as
similar to the request
of response message is
The structure
follows
< Status line>
<Header fields>
< Blank Line>
Reason phrase
Status code
HTTP version
codes.
used s t a t u s
some
commonly
table explains
Following
Description
Reason Phrase
Status successful
request
for
response
Code This is a
standard
requested password
The
provided any server is
U n a u t h o r i z e d user has not
the serverbut the
is present on
401 requested
resource
The it
to respond
not able
Forbidden
403
An up
thrust for knowledge
PUBLICATIONS-
TECHNICAL
Web Programming
1- 16 Fundamentals and Introduction to XHT
Therequested resource is not sent currenty but may b
Not Found
404 availablein future
It is a generic error meSsage thal appears due to softwa
500 Internal Server Error
internalfailure
2 We can omit the closing tags sometimes in For every tag there must be a closing tag. Somne
HTML document.
browsers get confused if the closing tag is not given
There are two ways by which we can mention the
cdosing tags
<a href "TajMahal.html" </a>
or
<a href-"Tajmahal.html/
3. In HTML the attribute values it not always In every XHTML document the attribute values
necessary to quote the attribute values. In must be quoted.
fact numeric attribute values are rarely
quoted in HTML Only if some special
characters or white spaces are present in the
attribute values then only it is essential to
put quotes around them in HTML
In HTML there are some implicit attribute In every XHTML the attribute values must be
values. specified explicitly.
5 In HTML even if we do not follow the In XHTML document the
nesting rules strictly it does not cause much
nesting rules
strictly followed. These nesting rules are must be
difference
A form element can not contain another
formelement.
An anchor element does not contan
another form element.
Review Question
O00
TML Docume
Java Script and XHTML Doc
2-2
Wet Progamming
the server.
displayed.
Every Document object has a property array called forms. Every Form object has
property arrays called elements. These elements contain the elements sucha
buttons and menus.
The Document object also has the property arrays for anchors, links, images and
applets.
The Document Object Model has been under development by w3C and it is
developed in various levels. These levels are
Level Description
DOM0 This model is supported by the early browsers. This level could support
JavaScript. This version was implemented in Netscape 3.0 and Internet
Explorer 3.0 browsers.
DOM 1 fhis version was issued in 1998 which was focused on XHTML and XML.
DOM 2 This version was issued in 2000 that could specify the styBe sheet. It also
supports the event modeland traversal with in the documents.
For example:
Consider following XHTML document
<htmi
<head
Stitle>This is MyWeb Page </title
</head
<body>
sh1>Hello Friends </h1>
h2>How are you?</h2>
<h3>See you</h3
slbody
The DOM tree will be as follows:
wwwwww nann
2-4
<body
<head
<h3
<h2>
<h1>
<title>
"See you"
"How are you?"
"Hello Friends" d o c u m e n t
web
for simple
"This is My Web Page" DOM
structure
Fig. 2.3.1
DOM node properties called
node.
DOM tree is
element in the root.
1. Every called the
DOM tree is
node in the
2. The topmost single node.
m u s t have a
parent
child node nodes.
Every called leaf
3 have n o
children are
bottommost
nodes that
4. The called siblings.
parent a r e
that have the
common
5. The nodes
Explain.
Nov 11. May-16. Marks 5
What is DOM?
3
XHTML Document
<html>
head
<title>This is My Web Page /title>
</head>
<body
TECHNICAL PUBLICATIONS-An up thrust for knowledge
Web Programming 2-5 JavaScript and XHTML Document
<form name="form1"
<input type-"text name="myinput"/>
</fom>
</body
</html>
Method1: Every XHTML document element is associated with some address. This
address is called DOM address. The document has the collection of forms and
elements. Hence we can refer the text box element i.e.
varDom Obj=document.forms[0].elements[0];
But this is not the suitable method of addressing the elements. Because if we change
the above script ass
Method 2: In this method we can make use of the name attribute in order to access the
desired element.
support the name attribute to the form element. Hence another way of accessing is
introduced.
var Dom_obj=document.getElementById("Food");
for(i =0;i< Dom_Obj.vegetables.length; it +)
document.write(Dom Obj.vegetableslij+"<br/>"
model.
Later on the complete and comprehensive event model is named DOMZ
specified.
Associated Tags
Events Tag Attribute Meaning
oinge ocus
hextarea>
<select>
Review Question
1. Define event and event handling
Question Bank.Model Question Paper
Dec.-17. Marks 2
2.6 Handling Events from Body Elements
For handling the event from
body element the most
commonly used events ar
onload and unload.
The onload event gets activated as soon as the web
page gets loaded in browser
window.
Example
JavaScript[Onload Demo.htmi]
<IDOCTYPE html>
<html>
<head>
<title> Demo of onload Tag Atibute </title
script type="text/javascript'>
function my fun()
on page loading
/This message will be displayed
alert("Welcome");
PUBLICATIONS- An up thrust
for knowiedge
TECHNICAL
Web Programming
2 9 JavaScript and XHTML Document
Weicome
Button Elements
2.7 Handling Events from
For handling the event using button element we have used the tag attribute
onclick.
The idea is that whenever we click the button some event handler must be called.
This event handler can be a user defined function in which certain set of
instructions get executed.
alert(Hello I am in my function );
/script
</head
<body
center
<form
Kinput type="button value "Click"
</form onclick="my fun()>
/center
</body
</html
Output
Demo of onlkick Tag Attibute Windows Internet Explores
2 D:UavaScript Ex OnclickDemo.html X ToggleEN Cust
Favorites E Suggested Sites e Get More Add-ons
Demo of onlclick Tag At.. Page Safety
Click
-rieros
Hello I am in my function
Computer P