You are on page 1of 11

[FALL 2015] ASSIGNMENT

NAME
PROGRAM

PATEL SHASHANK GIRISHBHAI


Master of Science in Information Technology (MSc
IT) Revised Fall 2011

SEMESTER

3rd Sem

SUBJECT CODE & NAME

MIT302- WEB TECHNOLOGY

Roll No

1408025004

CODE NO

03458

Q-1. Describe the following protocols:


a) IP
b) HTTP
c) FTP
d) SMTP
Ans: IP (Internet Protocol)
IP is the protocol that controls how data moves around on the network. After TCP
divides the message into segment, IP labels them with source and destination.
These packets are now called IP datagram. IP is the primary protocol in the Internet
Layer of the Internet protocol suite and has the task of delivering datagrams from
the source host to the destination host solely based on their addresses. IP also takes
care of sending the datagrams by determining the route. These datagrams may hop
several networks before reaching the destination.
HTTP
The Hypertext Transfer Protocol (HTTP) is a networking protocol for distributed,
collaborative, hypermedia information systems. HTTP is the foundation of data
communication for the World Wide Web.
FTP File Transfer Protocol)
Ftp is probably the most used resource on the Internet. It is a protocol which allows
users on computer to transfer files to another computer or we can say to exchange
files over the Internet. FTP works in the same way as HTTP (Hypertext Transfer
Protocol) for transferring web pages from a server to a users browser and SMTP

for transferring electronic mail across the Internet in that, like these technologies,
FTP uses the Internets TCP/IP protocols to enable data transfer.
When you take a file from a remote machine down to your own machine, it is
called a download. When the opposite happens and you place a file on a remote
machine, it is called on upload. FTP is most commonly used to download a file
from a server using the Internet or to upload a file to a server.
SMTP (Simple Mail Transfer Protocol)
SMTP is used for sending E-mail messages between servers. Most e-mail systems
that send mail over the internet use SMTP to send messages from one server to
another, the messages can then be retrieved with an e-mail client. In addition,
SMTP is generally used to send messages from a mail client to mail server.

Q-2 Describe the features of XML. What are the important rules to keep in
mind about the XML declaration?
Ans.
Features of XML:
XML is popular for many features and few of them are listed here
1.Easy Data Exchange: In XML, data and markup are stored as text
that we can configure. If we like, we can use XML editors to create
XML documents but if something goes wrong we can examine and
modify document directly because its all just text.XML provides a
very efficient way of storing most data. In addition, when we
standardize markup languages, many different people can use them.
2. Customizing markup language: We can create customized
markup languages using XML, and that represents its extraordinary
power. we can create a customized browsers to handle that language.
3. Self describing data: The data in XML document is self
describing. We can create our own tags in XML so that if we will go
back to our document years later, we can figure out whats going on.
4. Structured and integrated data: In XML document we can
specify not only data but the structure of that data can also be

specified. When we are dealing with complex and important data we


can integrate various elements in to other elements.
5. Well-formed XML documents: XML document must follow the
syntax rules set up properly. Each element also must nest inside any
enclosing elements properly. for example if in any example of XMl
we are opening a tag but not closing the same then it is not a well
formed XML document.
6. Valid XML document: An XML document is valid if there is a
document type definition (DTD) associated with it and if the
document complies with that DTD.
There are few other important rules to keep in mind about the
XML declaration:
a) The XML declaration is case sensitive: it may not begin with <?
XML or any other variant.
b) If the XML declaration appears at all, it must be the very first thing
in the XML document: not even whitespace or comments may
appear before it; and
c) It is legal for a transfer protocol like HTTP to override the
encoding value that you put in the XML declaration, so you cannot
guarantee that the document will actually use the encoding
provided in the XML declaration.
d) Elements may not overlap: an end tag must always have the same
name as the most recent unmatched start tag. The following
example is well-formed XML document.
The following example shows the tags properly nested:
<Education><student>distance education </student>
SMUDE</Education>
e) An XML document has exactly one root element. As a result, the
following example is not a well-formed XML document, because
both the university and books elements occur at the top level:
<! -- WRONG! -->
<University>...</university>
<Books>...</Books>
The following example fixes the problem by including both the
University and Books elements within a new Education root
element:

<Education>
<University>...</University>
<Books>...</Books>
</education>
Q-3

List and explain the Components of XML processor.

Ans.
Components of XML processor
a) Parser
Every XML processor has a parser. An XML parser converts an XML
document into an XML DOM object - which can then be manipulated
with a JavaScript. The parser's job is to translate XML markup and
data into a stream of bite-sized nuggets, called tokens, to be used for
processing. A token may be an element start tag, a string of character
content, the beginning delimiter of a processing instruction, or some
other piece of markup that indicates a change between regions of the
document.
In the following figure. We have conversed about XML parsing
process operates in three phases:

Figure: Three Stages of XML Parsing Process


Stage 1: In this stage, the application parses and validates the source
document; recognizes and searches for relevant information based on
its location or its tagging in the source document; extracts the relevant
information when it is located; and, optionally, maps and binds the
retrieved information to business objects.
Stage 2: Business logic handling. This is the stage in which the actual
processing of the input information takes place. It might result in the
generation of output information.
Stage 3: XML output processing. In this stage, the application
constructs a model of the document to be generated with the
Document Object Model (DOM). It then either applies XSLT style
sheets or directly serializes to XML.
b) Event switcher

The event switcher receives a stream of tokens from the parser and
sorts them according to function, like a switchboard telephone
operator of old. Some tokens signal that a change in behavior is
necessary. These are called events. One event may be that a
processing instruction with a target keyword significant to the XML
processor has been found. Another may be that a <title> element has
been seen, signaling the need for a font change. What the events are
and how they are handled are up to the particular processor. On
receiving an event, it routes processing to a subroutine, which is
called an event handler or sometimes a call-back procedure. This is
often all that the XML processor needs to do, but sometimes more
complex processing is required, such as building and operating on an
internal tree model.
c) Tree representation
The tree representation can take many forms, but there are two main
types. i) The first is a simple structure consisting of a hierarchy of
node lists. This is the kind of structure you would find in a non-objectoriented approach. ii) The other kind is called an object model, where
every node is represented as an object. In a programming phrase, an
object is a package of data and routines in a rigid, cloudy framework.
This style is preferred for large programs, because it minimizes certain
types of bugs and is usually easier to visualize. Object trees are
expensive in terms of speed and memory, but for many applications
this is an acceptable trade-off for convenience of development.
d) Tree processor
The tree processor is the part of the program that operates on the tree
model. It can be anything from a validity checker to a full-blown
transformation engine. It traverses the tree, usually in a methodical,
depthfirst order in which it goes to the end of a branch and backtracks
to find the last unchecked node. Often, its actions are controlled by a
list of rules, where a rule is some description of how to handle a piece
of the tree. For example, the tree processor may use the rules from a
style sheet to translate XML markup into formatted text.
Q-4 Describe the procedure of fetching data from XML to HTML. Give
an example.

Ans.
The process of fetching data from an XML files to be filled in an
HTML table, using DSO (Data Source Object) and JavaScript. DSO is an
object that operates like a database on the client side. It will accept
information that is organized in a certain way and will manipulate it with
its own database engine.
DSO allows data binding to HTML table elements. When a table element
is bound there is no need to write out the code for individual rows for
each record in the recordset. The DSO will automatically do this for each
record.
To bind the XML data to an HTML table, add a datasrc attribute to the
table element, and add the datafld attribute to the span elements inside
the table data.
For example
<table width="80%" id=nbbeqdatasrc="#equipdet" border="1">
<caption>
<span class="style1">example</span>
</caption>
<thead>
<tr>
......
</tr>
</thead>
<tbody>
<tr>
....
</tr>
</tbody>
</table>
Example using scripting:
Using JavaScript to load the XML file data to the HTML file using
DSO
First we create a new DSO via code:
<object id="nb_equip" CLASSID="clsid:550dda30-0541-11d29ca90060b0ec3d39" width="0" height="0">
</object>
Next we make a DOM object.This is done using the XMLDocument
property of the DSO.

var doc=nb_equip.XMLDocument;
Once a DOM object has been created use the load method of the
DOM object to load a file:
doc.load("equip.xml");
The following JavaScript function is used to load the XML file to
DSO objects. When the user calls this function it will load the XML
file and bind the data to the HTML table based on datasrc and datafld
attributes:
<html>
<body>
<script type="text/javascript">
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
Xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} xmlhttp.open("GET","cd_catalog.xml",false); xmlhttp.send();
xmlDoc = xmlhttp.responseXML;
document.write("<table border='1'>");
var x = xmlDoc.getElementsByTagName("CD");
for (i=0;i<x.length;i++)
{
document.write("<tr><td>");
document.write(x[i].getElementsByTagName("ARTIST")
[0].childNodes[0].no deValue);
document.write("</td><td>");
document.write(x[i].getElementsByTagName("TITLE")
[0].childNodes[0]. nodeValue);
document.write("</td></tr>");
}
document.write("</table>");
</script>
</body>
</html>

Q-5 Describe five different categories of PHP Operators.


Ans.
PHP Operators
In all programming languages, operators are used to manipulate or
perform operations on variables and values. There are many operators
used in PHP, so we have separated them into the following categories to
make it easier to learn them all.
Assignment Operators
Arithmetic Operators
Comparison Operators
String Operators
The Concatenation Operator
Assignment operators are used to set a variable equal to a value or set a variable
to another variable's value. Such an assignment of value is done with the "=", or
equal character.
Example:
$my_data= 2;
$another_data = $my_data
Now both $my_data and $another_data contain the value 2. Assignments
can also be used in conjunction with arithmetic operators.
Arithmetic operators are used to perform mathematical operations like
addition, subtraction, multiplication, division and Modulus. Table 1
shows all the arithmetic operators.
Table 1: Arithmetic Operator
Operator
+
*
/
%

English
Addition
Subtraction
Multiplication
Division
Modulus

Example
4+4
64
5*4
16 / 4
43 % 10

Comparison operators Comparisons are used to check the relationship between


variables and/or values. Comparison operators are used inside conditional

statements and evaluate to either true or false. Here are the most important
comparison operators of PHP. Assume: $x = 4 and $y = 5; Table 2 shows all the
comparison operators.
Table 2: Comparison Operator
Operato
r
==
!=
<
>
<=
>=

Meaning
Equal To
Not Equal To
Less Than
Greater Than
Less Then or Equal To
Greater Then or Equal
To

Exampl
e
$x == $y
$x != $y
$x < $y
$x > $y
$x <= $y
$x >= $y

String Operators As we have already seen in the Echo statement, the period "." is
used to add two strings together, or more technically, the period is the
concatenation operator for strings. By the following program you can see the
function of string operator.
PHP Code:
$a_string = "Distance";
$another_string = " Education!";
$new_string = $a_string .
$another_string;
echo $new_string . "!";
Output
Distance Education!

The Concatenation Operator There is only one string operator in PHP. The
concatenation operator (.) is used to put two string values together. To concatenate
two string variables together, use the concatenation operator:
<?php $txt1="Hello World!";
$txt2="Distance education!";

echo $txt1 . " " . $txt2; ?>


The output of the code above will be:
Hello World! Distance education!
Q-6 Describe about ASP.
Ans.
Introduction of ASP
Active Server Pages (ASPs) are Web pages that contain server-side
scripts in addition to the usual mixture of text and HTML (Hypertext
Markup Language) tags. Server-side scripts are special code that is put in
Web Pages and that code is processed before it is sent to the Web browser
of someone who's visiting your Web site. When we type a URL in the
Addressbox or click a link on a Web page it means we are asking a Web
server to send a file to the Web browser on our computer. If that file is a
normal HTML file, it looks exactly the same when your Web browser
receives it as it did before the Web server sent it. After receiving the file,
your Web browser displays its contents as a combination of text, images,
and sounds.
In the case of an Active Server Page, the process is similar, except there's
an extra processing step that takes place just before the Web server sends
the file. Before the Web server sends the Active Server Page to the Web
browser, it runs all server-side scripts contained in the page.
To distinguish them from normal HTML pages, Active Server Pages are
given the ".asp" extension. The basic difference between HTML and
ASP is that ASP is used to design user-interactive pages or dynamic
pages with database access whereas HTML is used to design static Pages.
How ASP Works?
Following are some steps that will help us to know about ASP working:
1. The user brings up a Web site where the default page has the extension
.asp.
2. The browser requests the ASP file from the Web server.
3. The server-side script begins to run with ASP.

4. ASP processes the requested file sequentially (top-down), executes any


script commands contained in the file, and produces an HTML Web
page.
5. The Web page is sent to the browser.
Because our script runs on the server, the Web server does all of the
processing and standard HTML pages can be generated and sent to the
browser. This means that our Web pages are limited only by what our
Web server supports. Another benefit of having our script reside on
the server is that the user cannot "view source" on the original script and
code. Instead,
the user sees only the generated HTML as well as non-HTML content,
such as XML, on the pages that are being viewed. Following figure
13.1 showsthe working of ASP page.

You might also like