Web Technologies 2068

Tribhuwan University
Institute of Science and Technology
2068
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.  Explain the web server concept. Why internet is a client/server technology?

10 marks view

Web server is a program or a computer that can provide services to other programs called clients. A web server can contain one or more websites. A web server processes the incoming requests.

  • The primary function of web server is to store, process and deliver web pages to clients. The communication between client and server takes place using the HTTP. Pages delivered are most frequently HTML documents, which ,may include images, style sheets.
  • A web browser initiates the communication by making a request for a specific resources using HTTP and the server responds with the content of that resources or an error message if unable to do so.

Web server features:

  • Always wait for a request from a client;
  • Serves clients’ requests, then responds with the requested data to clients;
  • A server can communicate with other servers in order to meet a client’s request.

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.

Internet is a client/server technology because most services that are accessed via the Internet work on the client/server model. In that, we have a server which provides a service, while clients connect to the server to make requests regarding the service. A web site is an example: a web server holds the contents of the web site. Our web browser is a client, which we can use to connect to web servers to ask them for information, or to perform services on our behalf.

2.  Define DTD. What are its applications? Create the HTML document with the paragraph using <p>,<h1>, <strong> for the first word for every sentence and <em> for all the capital letters.

10 marks view

DTD (Document Type Definition) defines the legal building blocks of an XML documents. It is used to define document structure with a list of legal elements and attributes. DTD can be classified on its declaration basis in the XML document, such as −

  • Internal DTD: A DTD is referred to as an internal DTD if elements are declared within the XML file.
  • External DTD: A DTD is referred to as an external DTD if elements are declared outside the XML file.

Application:

  • With a DTD, independent groups of people can agree on a standard DTD for interchanging data.
  • An application can use a DTD to verify that XML data is valid.

Now, 

<!DOCTYPE html>

<html>

 <head>

    <title>Nepal</title>

 </head>

 <body>

    <h1>My Country Nepal</h1>

    <p><strong><em>M</em>y</strong> country <em>N</em>epal is situated between two large countries <em>C</em>hina and <em>I</em>ndia <br />

    <strong><em>I</em>t</strong> is well known for it cultural diversity.<br/>

    <strong><em>P</em>eople</strong> around the world visit <em>N</em>epal for tourism.<br/>

  <strong><em>N</em>pal</strong>is agro-based country.<strong><em>S</em>ixty</strong> five percentage people completely depend on agriculture in <em>N</em>epal.</p>

 </body>

</html> 

3.  Design DOM for the time table of your classes in the present semester. Save at web server that is local or on the Internet. Later view it using the browser.

10 marks view

Fig: DOM of Time Table of Current Semester

Above diagram is a DOM implementation of Time table of current semester.

For simplicity, we display only on each day.

Lets write real implementation of DOM in XML file

<?xml version="1.0" encoding="utf-8"?>

<Six_Semester>

 <Day>

 <Sunday>

    <Time1>Compiler</Time1>

    <Time2>Software Engineering

    <Time3>Web Technology</Time3

    <Time4>Statistics</Time4>

    <Time5>Project Lab</Time5

 </Sunday>

 <Monday>

    <Time1>Compiler</Time1>

    <Time2>Software Engineering </Time2>

    <Time3>Web Technology</Time3>

    <Time4>Statistics</Time4>

    <Time5>Project Lab</Time5>

 </Monday>

 <Tuesday>

    <Time1>Compiler</Time1>

    <Time2>Software Engineering</Time2>

    <Time3>Web Technology</Time3>

    <Time4>Statistics</Time4>

    <Time5>Project Lab</Time5>

 </Tuesday>

 <Wednesday>

    <Time1>Compiler</Time1>

    <Time2>Software Engineering</Time2>

    <Time3>Web Technology</Time3>

    <Time4>Statistics</Time4>

    <Time5>Project Lab</Time5>

 </Wednesday>

 <Thursday>

    <Time1>Compiler</Time1>

    <Time2>Software Engineering</Time2>

    <Time3>Web Technology</Time3>

    <Time4>Statistics</Time4>

    <Time5>Project Lab</Time5>

 </Thursday>

 <Friday>

    <Time1>Compiler</Time1>

    <Time2>Software Engineering</Time2>

    <Time3>Web Technology</Time3>

    <Time4>Statistics</Time4>

    <Time5>Project Lab</Time5>

 </Friday>

 </Day>

</Six_Semester>


Let’s save in c: drive by named time_table.xml.

Viewing DOM Document in Browser

Just Type in Browser address bar : file:///C:/time_table.xml

Group B

Attempt any Eight questions:       (8x5=40)

4.  List the common application of web server.

5 marks view

Web server is a program or a computer that can provide services to other programs called clients. A web server can contain one or more websites. A web server processes the incoming requests.

  • The primary function of web server is to store, process and deliver web pages to clients. The communication between client and server takes place using the HTTP. Pages delivered are most frequently HTML documents, which ,may include images, style sheets.
  • A web browser initiates the communication by making a request for a specific resources using HTTP and the server responds with the content of that resources or an error message if unable to do so.

Here is the list of common application of web server

  • A web server‘s fundamental job is to accept and fulfill requests from clients for static content from a website (HTML pages, files, images, video, and so on).
  • The client is almost always a browser or mobile application and the request takes the form of a Hypertext Transfer Protocol (HTTP) message, as does the web server’s response.
  • web server in Java is used to host Java web application.
  • Web Server supports Servlets and JSP.

5.  Explain the functions of web caches.

5 marks view

A web cache is a HTTP cache for temporary storage of web documents such as HTML pages & images. It helps in temporary storage of frequently accessed static content.

Internet users with similar interests often download the same web content over and over again. Without a proper web cache, every time a user makes request the response must come from the origin server. When many users are requesting content at the same time, response time may increase and server overload may even occur.

Whenever content is downloaded from the origin server, a copy is stored in the web caches for a set period of time. If another user requests the same content again, the web caches sends the stored content and user request doesn't have to be forward to origin server again.

Web-cache flow:

1. A user access a website.

2. A browser sends an HTTP request to the web cache.

    i) If the requested object is stored in cache, the web cache responds with object.

    ii) If the requested object is not stored in cache, the web cache request the object from origin server and sends the response to the browser.

6.  What are the different types of headers in an HTTP message from a client? Explain.

5 marks view

HTTP header fields provide required information about the request or response, or about the object sent in the message body. There are four types of HTTP message headers:

  • General-header: These header fields have general applicability for both request and response messages.
  • Request-header: These header fields have applicability only for request messages.
  • Response-header: These header fields have applicability only for response messages.
  • Entity-header: These header fields define meta information about the entity-body or, if no body is present, about the resource identified by the request.

All the above mentioned headers follow the same generic format and each of the header field consists of a name followed by a colon (:) and the field value as follows:

    message-header = field-name ":" [ field-value ]

7.  What are the attributes of list tag? Explain.

5 marks view

HTML supports ordered, unordered and definition lists.

  • <ul> − An unordered list. This will list items using plain bullets.
  • <ol> − An ordered list. This will use different schemes of numbers to list your items.
  • <dl> − A definition list. This arranges your items in the same way as they are arranged in a dictionary.

By default, unorder list will list the items with it disc. We can use type attribute for <ul> tag to specify the type of bullet we like. Following are the possible options −

  • <ul type = "square">
  • <ul type = "disc">
  • <ul type = "circle">
E.g. 
<!DOCTYPE html>
<html>
   <head>
      <title>HTML Unordered List</title>
   </head>
   <body>
      <ul type = "square">
         <li>Ginger</li>
         <li>Potato</li>
         <li>Radish</li>
      </ul>
   </body>
</html>

In ordered list we can use type attribute for <ol> tag to specify the type of numbering we like. By default, it is a number. Following are the possible options −
  • <ol type = "1"> - Default-Case Numerals.
  • <ol type = "I"> - Upper-Case Numerals.
  • <ol type = "i"> - Lower-Case Numerals.
  • <ol type = "A"> - Upper-Case Letters.
  • <ol type = "a"> - Lower-Case Letters.
E.g. 
<!DOCTYPE html>
<html>
   <head>
      <title>HTML Ordered List</title>
   </head>
   <body>
      <ol type = "A">
         <li>Ginger</li>
         <li>Potato</li>
         <li>Radish</li>
      </ol>
   </body>
</html>

8.  What are the advantages of XML over the HTML?

5 marks view

Advantages of XML over HTML are:

  • XML encodes data in tightly-validated tree structures. Data is easy to locate since its context is well defined by tags and rules of structure.

  • HTML attempts to control the appearance and presentation of data, while XML does not. XML defines data separately from its presentation. This makes XML data easier to locate and manipulate.

  • XML is a standard data format that permits applications to exchange information across platforms and operating systems. HTML is markup used to display information in a web browser.

  • XML is open and extensible. XML authors can create their own tags. HTML is limited by a fixed vocabulary that browser developers have agreed to support. In fact, XML has no predefined tags of its own. New XML tags are defined as needed —to define any type of data using syntactical rules that that permit browsers and XML Parsers to interpret proprietary tags on the fly. 

  • Since XML is plain text, it is easily transmitted between computers and through firewalls. XML is more secure than binary files, since text files cannot be executed directly. Binary files, on the other hand, can contain malicious computer programs.

  • XML is universally compatible. The XML file format is not tied to any particular program, operating system, database, or network. XML can be used by non-web applications to store data.

  • XML files can be transformed into other types of documents. Transformation is controlled using XSL style sheets.

9.  How XSL is different from CSS? Explain.

5 marks view

XSL and CSS are two different languages recommended by the World Wide Web Consortium (W3C). XSL is more powerful and complex than CSS. Some of the difference between CSS and XSL are listed below:

  • XSL uses the XML notation that is helpful in writing the codes and the tools are provided in greater extent, whereas CSS doesn’t use any of the XML notations but has its own. 
  • XSL is having the formatting object tree setup differently from the source tree; whereas CSS is having the source tree and the formatting object tree the same.
  • XSL can’t provide the inheritance of the source tree using the formatting properties, whereas CSS provides the inheritance of the formatting object that is related to the source tree.
  • XSL is not supported by many of the web browsers, whereas CSS can be read by modern web browsers.
  • XSL is used to refer to a family of languages used to transform and render XML documents. CSS is a style sheet language used for describing the presentation semantics (the look and formatting) of a document written in a markup language.
  • XSL is designed to meet the needs of more complex applications for richer style sheets, whereas CSS is highly effective and easy to learn for simple applications.
  • XSL supports decision structures and can calculate quantities or store values in variable, whereas CSS doesn't support decision structures and it cannot calculate quantities or store values in variables.

10.  Why is it important to specify a DTD for an XML document? Explain.

5 marks view

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

Its main purpose is to define the structure of an XML document. It contains a list of legal elements and define the structure with the help of them.  A DTD can be declared inline inside an XML document, or as an external reference.

It is important to specify the a DTD for an XML document because:

  • It defines the different piece of data planning to model, along with their relationship.
  • With DTD, each of your XML files can carry a description of its own format with it.
  • With a DTD, independent groups of people can agree to use a common DTD for interchanging data.
  • Your application can use a standard DTD to verify that the data you receive from the outside world is valid.
  • You can also use a DTD to verify your own data.

Example of DTD:

<?xml version="1.0"?>  

<!DOCTYPE student [

<!ELEMENT student(firstname,lastname)>  

<!ELEMENT firstname (#PCDATA)>  

<!ELEMENT lastname (#PCDATA)>  

]>

<student>  

  <firstname>Jayanta</firstname>  

  <lastname>Poudel</lastname>  

</student>   

11.  What are the components of an XML file? Explain.

5 marks view

Components of an XML file are:

1. Processing Instructions:  

An XML Documents usually begins with the XML declaration statement called the Processing Instructions .This statement provides information on how the XML file should be processed.
e.g. <?xml version =”1.0” encoding=”UTF-8”?> 
The Processing Instruction statement uses the encoding property to specify the encoding scheme used to create the XML file

2. Tags:
Tags are used to specify a name for a given piece of information. It is a means of identifying data. Data is marked up using tags.
3. Elements:
Elements are the basic units used to identify and describe the data in XML. They are the building blocks of an XML document. Elements are represented using tags.

4. Content:

Content refers to the information represented by the elements of an XML document. Consider the following example:  
 <name>Jayanta</name >

Here Jayanta is content

5. Attributes:
Attributes provide additional information about the elements for which they are declared. An attribute consists of a name-value pair. Consider the following example:
<Student_name S_ID = “101”> Jayanta </ Student_name >
6. Entities:
An entity is a name that is associated with a block of data, such as chunk of text or a reference to an external file that contains textual or binary information. It is a set of information that can be specifying a single name.
7. Comments:
Comments are statements used to explain the XML code. They are used to provide documentation information about the XML file or the application to which the file belongs. The parser ignores comments entries during code execution.

12.  Differentiate between domain name and domain name system.

5 marks view

Domain Name: There is a massive number of websites available in the WWW. It is necessary to have a domain name to make a website visible to the user.  A domain name is a piece of string that helps to identify a website. For example, the domain of this website is “collegenote.pythonanywhere.com”. The domain name contains an extension to represent the type of the website or the company the website belongs too. The .com refers to a global company while .gov represents a government organization. Similarly, .org represents a non-government organization.

Domain Name System(DNS): Devices and services in the WWW use IP addresses. It is not possible for the users to type each IP address. DNS is the solution to this issue. When the user enters the domain in the web browser, the DNS server converts the domain name to the corresponding IP addresses. 

Difference Between Domain and DNS - Pediaa.Com

Fig: DNS

The main difference between domain name and DNS is that the domain name is a piece of string that helps to identify a particular website while the DNS (Domain Name System) is a server that translates the domain to the corresponding IP address to provide the required webpage.

13.  Explain the form handling with example.

5 marks view

Handling forms is a multipart process. First a form is created, into which a user can enter the required details. This data is then sent to the web server, where it is interpreted, often with some error checking.

PHP Form Handling with POST

If we specify the form method to be POST, then the form-data is sent to the server using the HTTP POST method.

syntax:

<?php

 $_POST['variable_name'];

?>

E.g. 

//form1.html

<form action="login.php" method="post">   

<table>   

<tr><td>Name:</td><td> <input type="text" name="name"/></td></tr>  

<tr><td>Password:</td><td> <input type="password" name="password"/></td></tr>   

<tr><td colspan="2"><input type="submit" value="login"/>  </td></tr>  

</table>  

</form>   

//login.php

<?php  

$name=$_POST["name"];   //receiving name field value in $name variable  

$password=$_POST["password"];   //receiving password field value in $password variable  

echo "Welcome: $name, your password is: $password";  

?>  

PHP Form Handling with GET

If we specify the form method to be GET, then the form-data is sent to the server using the HTTP GET method.

syntax:

<?php

$_GET['variable_name'];

?>

E.g. 

//form1.html

<form action="welcome.php" method="get">  

    Name: <input type="text" name="name"/>  

    <input type="submit" value="visit"/>  

</form>  

//welcome.php

<?php  

$name=$_GET["name"];    //receiving name field value in $name variable  

echo "Welcome, $name";  

?>