Monday 1 August 2016

ASSIGNMENT OF WEB TECHNOLOGIES

Question No.1 Differentiate TCP and UDP?
TCP (Transmission Control Protocol):-
The TCP corresponds to the transport layer of OSI reference model, The TCP is known as a connection-oriented protocol, which means that a connection is established and maintained until such time as the message or messages to be exchanged by the application programs at each end have been exchanged. TCP makes sure data gets to the destination without errors. It is also responsible for disassembling and assembling the data. It divides large messages into smaller packets of at the most 15KB size. Each of this packet is called a segment. TCP numbers these segments and hand it over to IP layer.
TCP is used along with the Internet Protocol (IP) to send data in the form of message units between computers over the Internet. While IP takes care of handling the actual delivery of the data, TCP takes care of keeping track of the individual units of data (called packets) that a message is divided into for efficient routing through the Internet.
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 datagrams. 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.
UDP (User Datagram Protocol):-
UDP is connection-less transport layer protocol. The UDP port identifies various applications running on a device. UDP adds no reliability, flow control or error recovery. Each datagram is independent of others, and they may be lost by the networks or arrive out of order. A receiving system remains unaware of the sending of a datagram unless it arrives. UDP is used in situations where reliability is not required and it is helpful in multimedia and multicasting applications. 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 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 user's browser and SMTP for transferring electronic mail across the Internet in that, like these technologies, FTP uses the Internet's TCP/IP protocols to enable data transfer.

Question No. 2 Describe the features of XML. What are the important rules to keep in mind about the XML declaration?
Features of XML:-
XML stands for Extensible Markup Language. The real use of XML, though, is to describe data. The only thing we have to learn about XML is how to structure your tags, and they are in fact almost identical to HTML tags. XML is a popular and widely-implemented standard: we can use XML to create documents and data records that are fully portable and platform-independent.
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 it’s 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 what’s 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.
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>
Question No. 3 Define three stages of XML parser process through suitable diagram. Differentiate SAX and DOM?
Parser Process:-
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:
Text Box: XML Input Processing
 




                              
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.

Difference between SAX and DOM
We use DOM for internal presentation of XML. It is good for small XML file but bad for large files because when we use DOM for large file it present whole file into the memory. Where SAX is work on particular event so, it can use to find out the specific element of XML doc. It cannot present data of XML. It works from top to bottom in XML file. We can't use SAX without DOM. The following table shows the difference between DOM and SAX technology.
Table Difference between SAX and DOM






DOM
SAX
Standardization
W3C Recommendation

No formal specification

Manipulation
Reading and writing (manipulation)

Only reading

Memory consumption
Depends on the size of the source xml-file, can be large

Very low
XML handling

Tree-based

Event-based



SAX uses event-driven model for reading xml-documents. The basic idea is that SAX parser reads the xml-document “one line at a time”. In SAX handler functions reacts when finding elements and other parts of the xml-document.
by the different approaches that these specifications take in the parsing process. SAX parsers process the XML document sequentially while DOM parsers typically load the entire document into memory and store it in a tree structure. A SAX parser reads through the input XML document, and notifies us of any interesting events.
Question No. 4 Describe the procedure of fetching data from XML to HTML. Give an example.
XML Data into an HTML Page:-
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.
Example  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-11d2-9ca9-0060b0ec3d39" 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].nodeValue);
document.write("</td><td>");
document.write(x[i].getElementsByTagName("TITLE")[0].childNodes[0]. nodeValue);
document.write("</td></tr>");
}
document.write("</table>");
</script>
</body>
</html>
Question No. 5 Describe five different categories of PHP Operators.
1. Assignment operators:-
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.
2. Arithmetic operators:-
Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication, division and Modulus.
Operator
English
Example
+
Addition
2+8
-
Subtraction
8-4
*
Multiplication
5*7
/
Division
10/5
%
Modulus
11%5

3. Comparison operator: -
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 11.2 shows all the comparison operators.
OPERATOR 
Meaning
Example
==
Equal to
A==b
!=
Not Equal to
C!=d
< 
Less then
B<a
> 
Greater then
D>s
<=
Less then or Equal to
D<=d
>=
Greater then or Equal to
A>=d

4. 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
$_string = “Nick Name”;
$another_string = “Akki”;
$new_string = $a_string . $another_string;
Echo $new_string .”!”;
Output
Nick Name Akki
5. 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="Akash Verma!";
echo $txt1 . " " . $txt2; ?>
The output of the code above will be:
Hello World! Akash Verma!
Question No. 6 Explain various components of AJAX?
AJAX Components:-
Ajax is a set of technologies, supported by a web browser, including these elements:
1. HTML and CSS for presenting.
2. JavaScript for local processing, and DOM (Document Object Model) to access data inside the page or to access elements of XML file read on the server .
3. The XMLHttpRequest class read or sends data on the server asynchronously.
Ajax frameworks component offer pre-built components, such as tabbed panes, which automatically create and manage their own HTML. Components are generally created via JavaScript or XML tags, or by adding special attributes to normal HTML elements. These frameworks are generally larger, and intended for web applications rather than web sites. Some component frameworks require the developer to have extensive HTML/CSS/Ajax experience and to do cross-browser testing.
 For example, grids, tabs, and buttons may be provided, but user input forms are expected to be authored directly in HTML/CSS and manipulated via Ajax techniques. Other frameworks provide a complete component suite such that only general XML and/or JavaScript abilities are required. Ajax component frameworks can enable more rapid development than direct Ajax frameworks, but with less control, Ajax component framework provides the following:
1. customization APIs, e.g., an event that fires when the user stops editing within a grid
2. skinning facilities, where appearance can be changed without affecting behavior or layout
3. programmatic control, e.g., dynamically adding tabs or dynamically creating components based on user data
4. extensibility – creation of new components based on other components, so that the benefits of a component-based framework are not lost
Allows user to continue interacting with web page while waiting for data to be returned  Page can be updated without refreshing browser Results in a better user experience There are Ajax libraries that reduce the amount of JavaScript code that must be written The use of XMLHttpRequest in 2005 by Google, in Gmail and Google Mapshas contributed to the success of this format.
---------------------------------------------------------------------------------------------------

No comments:

Post a Comment