Web Technologies 2068-II

Tribhuwan University
Institute of Science and Technology
2068-II
Bachelor Level / Sixth Semester / Science
Computer Science and Information Technology ( CSC-353 )
( Web Technologies )
Full Marks: 60
Pass Marks: 24
Time: 3 hours
Candidates are required to give their answers in their own words as far as practicable.
The figures in the margin indicate full marks.

Group A

Attempt any Two questions:       (2x10=20)

1.  How does a web server link physically on the Internet? How do we navigate from one URL to another from a page displayed at a browser? Explain.

10 marks view

The web server works as follows:

  • A user enters a URL into a browser (for example, google.com). This request is passed to a domain name server.
  • The domain name server returns an IP address for the server that hosts the Website (for example, 68.178.157.132).
  • The browser requests the page from the Web server using the IP address specified by the domain name server.
  • The Web server returns the page to the IP address specified by the browser requesting the page. The page may also contain links to other files on the same server, such as images, which the browser will also request.
  • The browser collects all the information and displays to your computer in the form of Web page.


Navigation in web page is simple. It use a single link tag termed as Anchor Tag <a>. By using anchor tag we can navigate from different portion of site, another web site. Generally navigation has three techniques

• Internal navigation (Navigation inside site)

• External Navigation (Navigate to third party site)

• Intra Navigation (Navigate with in web page for easy scrolling)

The following example demonstrate navigation technique in web browser.

<html>

 <head>

 <title>Navigation example</title>

 </head>

 <body>

    <h2 id="C4">Chapter 4</h2>

    <a href="#C4">Jump to Chapter 4</a>

    <a href="/images/flower.jpg">Open flower Picture of site (internal Link)</a>

    <a href="http://www.facebook.com/collegenote">Open facebook site (External Link)</a>

 </body>

 </html> 

2.  List the protocols and their use at the application layer in the Internet. Why World Wide Web is use? Explain.

10 marks view

An application layer protocol defines how application processes (clients and servers), running on different end systems, pass messages to each other. Some protocols used in application layer are discussed below:

1. HTTP (Hypertext Transfer Protocol):

    This is a protocol used mainly to access data on the world wide web(WWW). It is a protocol which governs the communication between the client and server.

2. TELNET (Terminal Network):

    TELNET is a client-server application that allows a user to log onto remote machine and lets the user to access any application program on a remote computer.

3. FTP (File Transfer Protocol):

    FTP is the standard mechanism provided by TCP/IP for transferring a file from one host to another. Transferring file from a client computer to a server computer is called uploading and transferring from server to a client is downloading. 

4. SMTP (Simple Mail Transfer Protocol)

    The TCP/IP protocol that supports electronic mail on the internet is called SMTP. It transfers messages from senders' mail servers to the recipents' mail servers using TCP connections. SMTP provides services for mail exchange between users on the same or different computers.

5. POP (Post Office Protocol):

    This is a protocol used by a mail server in conjunction with SMTP to receive and holds mail for hosts. POP3 mail server receives e-mails and filters them into the appropriate user folders. When a user connects to the mail server to retrieve his mail, the messages are downloaded from mail server to the user's hard disk.


The World Wide Web (WWW) is a system that we use to access the Internet. The WWW is hypertext based information retrieval tool, it uses the hypertext to access the various forms of information available on the world’s different networks. One can easily surf the Web by jumping from one document to another using the links in those documents. These documents can be in many formats, such as text, graphics, animation, sound and latest is video. They may also be a combination of all these. All the information on Internet are presented to the user as a document or more popularly known as Web Page. All these Web Pages are link to each other or even to section within a Web Page. And these links are known as Hyper Links.

3.  What is DOM Hierarchy? Explain the use of *, ? and + in defining a DOM element.

10 marks view

Every web page resides inside a browser window which can be considered as an object. A Document object represents the HTML document that is displayed in that window. The Document object has various properties that refer to other objects which allow access to and modification of document content.

The way a document content is accessed and modified is called the Document Object Model, or DOM. The Objects are organized in a hierarchy. This hierarchical structure applies to the organization of objects in a Web document.

Here is a simple hierarchy of a few important objects −

DOM HTML tree


*, ? and + are the part of regular expression.

A asterisk(*) indicates that the preceding character should appear zero or more times in the pattern.

  • The pattern fo* can be found in"fd", "fod", "food", "foood" etc.

A questionmark(?) indicates that the preceding character should appear zero or one times in the pattern.

  • The pattern foo? can be found in "food" and "fod" but not "faod".

A plus sign(+) indicates that the preceding character should appear one or more times in the pattern.

  • The pattern fo+ can be found in "fod", "food" and "foood", but not "fd".

Group B

Attempt any Eight questions:       (8x5=40)

4.  What are the tags and attributes for a table in HTML document?

4 marks view

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). The letters td stands for "table data," which is the content of a data cell. A data cell can contain text, images, lists, paragraphs, forms, horizontal rules, tables, etc. Headings in a table are defined with <th> tag.

Table tags:

Table tags attributes:

E.g.

<!DOCTYPE html>

<html>

<head>

<title>Table</title>

</head>

<body>

<h1>The table element</h1>

<table border="1">

  <tr>

    <th>Month</th>

    <th>Savings</th>

  </tr>

  <tr>

    <td>January</td>

    <td>$100</td>

  </tr>

  <tr>

    <td>February</td>

    <td>$80</td>

  </tr>

</table>

</body>

</html>

5.  Write short notes on various services offered by the Internet.

5 marks view

The Internet is a global system of interconnected computer networks that use the standard Internet protocol suite (often called TCP/IP, although not all applications use TCP) to serve billions of users worldwide. It is a network of networks that consists of millions of private, public, academic, business, and government networks, of local to global scope, that are linked by a broad array of electronic, wireless and optical networking technologies. The Internet carries an extensive range of information resources and services, such as the inter-linked hypertext documents of the World Wide Web (WWW) and the infrastructure to support email.

The Internet can:

  • Exchange electronic mail (e-mail) to any Internet user in any location on the planet.
  • Participate in off-line (indirectly, not in real time) discussions via e-mail with people with similar interests through 'mailing lists' and 'News Groups'.
  • Participate live (in real time) in a conversation with another person via the 'Internet video phone' (like Skype), or audio-video conferencing between multiple people using a specially designed computer programs and equipment.
  • Participate in on-line (directly, in real time) written discussion with a larger group of people who use the 'Internet Relay Chat' (IRC) service - chat rooms.
  • To work on a remote computer using the 'Telnet' service or some per function quite the same.
  • Take files of any type (download) from remote computers and deliver files (upload) them with an FTP (File Transfer Protocol) service.
  • Reading complex documents using 'hypertext'. Clicking on a keyword or image on the screen the user is automatically goes to other facilities within the same or other domains.
  • Read multimedia documents found on WWW (World Wide Web) that contain text, graphics, sound, and video using intelligent browser web presentation, as 'Google Chrome', 'Firefox' or 'Internet Explorer' program support.
  • Learning and practicing for the exam and achieve appropriate certification.
  • Search the Web, documents, various WWW sites or via dedicated international service, as 'Google' and 'Yahoo!', over subscribed keywords to find the desired documents.
  • Publicly disclose their images or pictures of his grandchildren, and who wants to can publish a picture of mother in law.
  • Advertise your business in a variety of ways, from setting up video clips to the creation of their own website.
  • Paying bills through the 'Internet Banking'.
  • Buy and spend money : advertise and offer for sale.
  • Read web editions of newspapers or say 'IT Alphabet'.

6.  What is the functionality and purpose of HTTP?

5 marks view

HTTP is a TCP/IP based communication protocol, that is used to deliver data (HTML files, image files, query results, etc.) on the World Wide Web. The default port is TCP 80, but other ports can be used as well. It provides a standardized way for computers to communicate with each other. HTTP specification specifies how clients' request data will be constructed and sent to the server, and how the servers respond to these requests.

There are three important features of HTTP:

  • HTTP is connectionless: After a request is made, the client disconnects from the server and waits for a response. The server must re-establish the connection after it processes the request.
  • HTTP is media independent: Any type of data can be sent by HTTP as long as both the client and server know how to handle the data content. How content is handled is determined by the MIME specification.
  • HTTP is stateless: This is a direct result of HTTP's being connectionless. The server and client are aware of each other only during a request. Afterwards, each forgets the other. For this reason neither the client nor the browser can retain information between different requests across the web pages.

The following diagram shows a very basic architecture of a web application and depicts where HTTP sits:

HTTP Architecture

The HTTP protocol is a request/response protocol based on the client/server based architecture where web browsers, robots and search engines, etc. act like HTTP clients, and the Web server acts as a server.

Client:

The HTTP client sends a request to the server in the form of a request method, URI, and protocol version, followed by a MIME-like message containing request modifiers, client information, and possible body content over a TCP/IP connection.

Server:

The HTTP server responds with a status line, including the message's protocol version and a success or error code, followed by a MIME-like message containing server information, entity meta information, and possible entity-body content.

7.  Explain the XML syntax and structure rules.

5 marks view

The syntax rules of XML are very simple and logical. The rules are easy to learn, and easy to use.

XML syntax and structure rules are:

1. All XML Elements Must Have a Closing Tag. In XML, it is illegal to omit the closing tag. All elements must have a closing tag:

    E.g. Correct: <p>This is a paragraph.</p>

           Incorrect: <p>This is a paragraph.

2. XML tags are case sensitive. The tag <Letter> is different from the tag <letter>. Opening and closing tags must be written with the same case:

   E.g. Incorrect: <Message>This is incorrect</message>   

       Correct: <message>This is correct</message>    

3. In XML, all elements must be properly nested within each other:

    E.g. Incorrect: <b><i>This text is bold and italic</b></i>

        Correct: <b><i>This text is bold and italic</i></b>

4. XML Documents Must Have a Root Element. XML documents must contain one element that is the parent of all other elements. This element is called the root element.

<root>

    <child>

        <subchild>.....</subchild>

    </child>

</root>

5. XML Attribute Values Must be Quoted.

<note date="06/01/2012">

    <to>Tulsi</to>

    <from>Giri</from>

</note>

6. Comments in XML.

The syntax for writing comments in XML is similar to that of HTML.

    <!-- This is a comment -->

7. White-space is preserved in XML. 

8. Avoid HTML tags.

8.  Mention the application of XSL.

5 marks view

Separating format from content is all well and good, but sooner or later you need to format information for presentation. XML by itself is not acceptable for display to the average user. The technology for formatting XML presentation is eXtensible Stylesheet Language (XSL). Unlike traditional style sheets, which provide only formatting commands, XSL is a powerful mechanism for both transforming and formatting XML documents.

XSL is an XML markup language itself and as such, can

  • Format content for online display or for paper-based delivery

  • Add constant text or graphics (such as the icons in the "warning" example)

  • Filter content

  • Sort or reorder text

9.  What are the benefits and drawbacks of using XML name space?

5 marks view

XML Namespace is a mechanism to avoid name conflicts by differentiating elements or attributes within an XML document that may have identical names, but different definitions.

Consider two XML fragment:

//1.xml

<table>

  <tr>

    <td>Apples</td>

    <td>Bananas</td>

  </tr>

</table>

//2.xml

<table>

  <name>African Coffee Table</name>

  <width>80</width>

  <length>120</length>

</table>

If these XML fragments were added together, there would be a name conflict. Both contain a <table> element, but the elements have different content and meaning.

Name conflicts in XML can easily be avoided using a name prefix.

E.g.

<h:table>

  <h:tr>

    <h:td>Apples</h:td>

    <h:td>Bananas</h:td>

  </h:tr>

</h:table>

<f:table>

  <f:name>African Coffee Table</f:name>

  <f:width>80</f:width>

  <f:length>120</f:length>

</f:table>

In this example, there will be no conflict because the two <table> elements have different names.

Advantages
  • It helps us avoid real name clashes with other XML vocabularies.
  • Moreover, namespaces may be used, if XML documents will be distributed to others, when name collisions may really become an issue.
Disadvantages
  • Namespaces, increases the size of XML documents.
  • With namespaces, we need to be extra careful while writing applications (all our programming expressions, querying & creating the XML nodes must be namespace aware). This namespace-awareness overhead (effort to create, and maintain) should be incurred, only if an application requires it (i.e, if management of name collisions is really needed).

10.  What is the syntax of declaring an attributes in a DTD?

5 marks view

 DTD defines the legal building blocks of an XML document. It is used to define document structure with a list of legal elements and attributes.

An attribute declaration in DTD has the following syntax:

<!ATTLIST element-name attribute-name attribute-type attribute-value>

  • element-name specifies the name of the element to which the attribute applies.
  • attribute-name specifies the name of the attribute which is included with the element-name.

The attribute-type can be one of the following:

The attribute-value can be one of the following:



E.g.

DTD example:

<!ATTLIST employee id CDATA #REQUIRED> 

XML example:

<employee id="001" />

11.  Explain briefly, how the domain names are translated to IP addresses.

5 marks view
DNS (Domain Name System) is what translate domain name (for eg. www.google.com) into an IP address that our browser can use (for eg. 173.194.35.148). Before the page is loaded, the DNS must be resolved so the browser can establish a TCP connection to make the HTTP request. The DNS Resolution process starts when the user types a URL address on the browser and hits Enter.

The DNS works as follows:
  1. A user types ‘example.com’ into a web browser and the query travels into the Internet and is received by a DNS recursive resolver.
  2. The resolver then queries a DNS root nameserver (.).
  3. The root server then responds to the resolver with the address of a Top Level Domain (TLD) DNS server (such as .com or .net), which stores the information for its domains. When searching for example.com, our request is pointed toward the .com TLD.
  4. The resolver then makes a request to the .com TLD.
  5. The TLD server then responds with the IP address of the domain’s nameserver, example.com.
  6. Lastly, the recursive resolver sends a query to the domain’s nameserver.
  7. The IP address for example.com is then returned to the resolver from the nameserver.
  8. The DNS resolver then responds to the web browser with the IP address of the domain requested initially.
  9. Once the 8 steps of the DNS lookup have returned the IP address for example.com, the browser is able to make the request for the web page:

  10. The browser makes a HTTP request to the IP address.
  11. The server at that IP returns the webpage to be rendered in the browser (step 10).

12.  Explain the client/server concepts of web.

5 marks view

Client-server is a computer model that separates client and server, and usually interlinked using a computer network. Each instance of a client can send data requests to one of the servers online and expect a response. In turn, some of the available servers can accept these requests, process them and return the result to the client. Often clients and servers communicate through a computer network with separate hardware, but the client and server can reside on the same system. The machine is a host server that is running one or more server programs that share their resources with clients. A client does not share its resources, but requests content from a server or service function. Clients, therefore, initiate communication sessions with the servers that wait for incoming requests.

13.  What do you mean by cookies? Explain with example.

5 marks view

A cookie is a variable that is stored on the visitor's computer. Cookies let you store user information in web pages.

When a web server has sent a web page to a browser, the connection is shut down, and the server forgets everything about the user. Cookies were invented to solve the problem "how to remember information about the user".

  • When a user visits a web page, his/her name can be stored in a cookie.
  • Next time the user visits the page, the cookie "remembers" his/her name.

Cookies are saved in name-value pairs like:

    username = Ronaldo

When a browser requests a web page from a server, cookies belonging to the page are added to the request. This way the server gets the necessary data to "remember" information about users.

JavaScript Cookies

E.g.

JavaScript code to set and get a cookie:

<!DOCTYPE html>  

<html>  

<head>  

</head>  

<body>  

<input type="button" value="setCookie" onclick="setCookie()">  

<input type="button" value="getCookie" onclick="getCookie()">  

    <script>  

    function setCookie()  

    {  

        document.cookie="username=Jayanta";  

    }  

    function getCookie()  

    {  

        if(document.cookie.length!=0)  

        {  

        alert(document.cookie);  

        }  

        else  

        {  

        alert("Cookie not available");  

        }  

    }  

    </script>  

</body>  

</html>