Web Technologies 2069

Tribhuwan University
Institute of Science and Technology
2069
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 2-Tier, 3-Tier and n-Tier technology with its architecture.

10 marks view

2-Tier Architecture

2-tier architecture is used to describe client/server systems where the client requests resources and the server responds directly to the request, using its own resources. This means that the server does not call on another application in order to provide part of the service. It runs the client processes separately from the server processes, usually on a different computer.

Networking: 3-Tier Client/Server Architecture - CCM

3-Tier Architecture

In 3-tier architecture, there is an intermediary level, meaning the architecture is generally split up between:

 A client, i.e. the computer, which requests the resources, equipped with a user interface (usually a web browser) for presentation purposes

– The application server (also called middleware), whose task it is to provide the requested resources, but by calling on another server

– The data server, which provides the application server with the data it requires.

Networking: 3-Tier Client/Server Architecture - CCM

N-Tier Architecture (multi-tier)

N-tier architecture (with N more than 3) is really 3 tier architectures in which the middle tier is split up into new tiers. The application tier is broken down into separate parts. These parts are differs from system to system. The primary advantage of N-tier architectures is that they make load balancing possible. Since the application logic is distributed between several servers, processing can then be more evenly distributed among those servers. N-tiered architectures are also more easily scalable, since only servers experiencing high demand, such as the application server, need be upgraded. The primary disadvantage of N-tier architectures is that it is also more difficult to program and test an N-tier architecture due to its increased complexity. 

 

2.  Create a small XML file designed to contain information about student performance on a module. Each student has a name, roll no, a subject mark and an exam mark.

10 marks view

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

 <performance>

    <student>

        <Name>Barsha</Name>

        <Roll_Number>1</Roll_Number>

        <Subject_Mark>80</Subject_Mark>

        <Exam_Mark>30</Exam_Mark>

    </student>

    <student>

        <Name>Priyanka</Name>

        <Roll_Number>2</Roll_Number>

        <Subject_Mark>80</Subject_Mark>

        <Exam_Mark>45</Exam_Mark>

    </student>

    <student>

        <Name>Swastima</Name>

        <Roll_Number>3</Roll_Number>

        <Subject_Mark>80</Subject_Mark>

        <Exam_Mark>55</Exam_Mark>

    </student>

    <student>

        <Name>Rashmika</Name>

        <Roll_Number>4</Roll_Number>

        <Subject_Mark>80</Subject_Mark>

        <Exam_Mark>65</Exam_Mark>

    </student>

</performance>

3.  Using test structuring toys, create a homepage for the curriculum vitae. Save at web server that is local or on the internet. Later view it using the browser.

10 marks view

<!DOCTYPE html>

 <html>

 <head>

 <title>Curriculum Vitae</title>

 </head>

 <body>

    <form id="form1" runat="server">

    <h1>Curriculum Vitae</h1>

    <div>

    <br />

    <table style="width:100%;">

    <tr>

        <td>Name:</td>

        <td>Manish Poudel</td>

    </tr>

    <tr>

        <td>Father Name</td>

        <td>Binod Poudel</td>

    </tr>

     <tr>

         <td>DOB:</td>

         <td>12<sup>th</sup> OCT 1998</td>

    </tr>

    <tr>

        <td>Temporary Address:</td>

        <td>Kathmandu</td>

    </tr>

    <tr>

        <td>Permanent Address</td>

        <td>Ramechhap</td>

    </tr>

    <tr>

        <td>Marital Status</td>

        <td>Unmarried</td>

    </tr>

    <tr>

        <td>&nbsp;</td>

        <td>&nbsp;</td>

    </tr>

    </table>

    </div>

 </form>

    <table style="width:100%;" >

    <tr>

        <td>Educational Information</td>

        <td>&nbsp;</td>

        <td>&nbsp;</td>

    </tr>

    <tr>

        <td>&nbsp;</td>

        <td>&nbsp;</td>

        <td>&nbsp;</td>

    </tr>

    <tr>

        <td>Degree</td>

        <td>Passed Year</td>

        <td>Percentage</td>

    </tr>

    <tr>

        <td>SLC</td>

        <td>2070 B.S.</td>

        <td>83</td>

    </tr>

    <tr>

        <td>+2 </td>

        <td>2073 B.S.</td>

        <td>74</td>

    </tr>

    <tr>

        <td>Bsc. CSIT </td>

        <td>Running</td>

        <td>N/A</td>

    </tr>

 </table>

 <br />

 Achievements:<br />

 <ul>

    <li>First Prize on Graphic Design in INFOTEC Festival</li>

    <li>Second Prize on On spot Software Development Inter college Competition</li>

    <li>Second Prize in Swimming Competition Olympic 2014</li>

 </ul>

 </body>

</html>


Let’s save in E: drive by named cv.html.

Viewing CV in Browser

Just Type in Browser address bar : file:///E:/cv.html

Group B

Attempt any Eight questions:       (8x5=40)

4.  Explain the uses of a 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.

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.

Basic functionality:

  • It receives HTTP request via TCP
  • It maps Host header to specific virtual host (one of many host names sharing an IP address)
  • It maps Request-URI to specific resource associated with the virtual host

                - File: Return file in HTTP response

                - Program: Run program and return output in HTTP response

  • It maps type of resource to appropriate MIME type and use to set Content-Type header in HTTP response
  • It Logs information about the request and response
  • All e-commerce site require basic Web server software to answer requests from customers like ; Apache ,Microsoft’s Internet Information Server (IIS)

5.  Explain the SMTP with example.

5 marks view

Simple Mail Transfer Protocol (SMTP) is an Internet standard for electronic mail (email) transmission across Internet Protocol (IP) networks. SMTP (Simple Mail Transfer Protocol) is a TCP/IP protocol used in sending and receiving e-mail. However, since it is limited in its ability to queue messages at the receiving end, it is usually used with one of two other protocols, POP3 or IMAP, that let the user save messages in a server mailbox and download them periodically from the server. In other words, users typically use a program that uses SMTP for sending e-mail and either POP3 or IMAP for receiving e-mail. On Unix-based systems, send mail is the most widely-used SMTP server for e-mail. A commercial package, Send mail, includes a POP3 server. Microsoft Exchange includes an SMTP server and can also be set up to include POP3 support.

SMTP usually is implemented to operate over Internet port 25. An alternative to SMTP that is widely used in Europe is X.400. Many mail servers now support Extended Simple Mail Transfer Protocol (ESMTP), which allows multimedia files to be delivered as e-mail.

An SMTP server performs two functions:

  • Verifies proper configuration and grants permission to a computer attempting to send a message.
  • Sends an outgoing message to a predefined destination and tracks the successful delivery of the message. If it is not deliverable, a message is sent back to the sender. All SMTP servers use their own code which identifies them. For instance, if you are using Hotmail to send e-mail. You would need to configure a mail client, such as Outlook Express with the following code: smtp.hotmail.com

6.  What are the color attributes in HTML? Explain.

5 marks view

Colors are very important to give a good look and feel to your website. We can specify colors on page level using <body> tag or you can set colors for individual tags using bgcolor attribute.

The <body> tag has following attributes which can be used to set different colors −

  • bgcolor − sets a color for the background of the page.
  • text − sets a color for the body text.
  • alink − sets a color for active links or selected links.
  • link − sets a color for linked text.
  • vlink − sets a color for visited links − that is, for linked text that you have already clicked on.

There are following three different methods to set colors in your web page −

  • Color names − We can specify color names directly like green, blue or red.
  • Hex codes − A six-digit code representing the amount of red, green, and blue that makes up the color.
  • Color decimal or percentage values − This value is specified using the rgb( ) property.

E.g. 

<!DOCTYPE html>

<html>

   <head>

      <title>HTML Colors by Name</title>

   </head>

   <body text = "blue" bgcolor = "green">

      <p>Use different color names for for body and table and see the result.</p>

      <table bgcolor = "black">

         <tr>

            <td>

               <font color = "white">This text will appear white on black background.</font>

            </td>

         </tr>

      </table>

   </body>

</html>

7.  What are the important uses of cookies? Give some examples.

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>  

8.  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.

9.  How is XML defined? What are the benefits of using XML namespace?

5 marks view

XML (Extensible Markup Language) is  a markup language that defines a set of rules for encoding documents in a format that is both human readable and machine readable. XML is designed to store and transport data.


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.

Benifits of XML Namespace
  • 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.

10.  What are the various contents of an element in a DTD? Explain.

5 marks view

XML elements can be defined as building blocks of an XML document. Elements can behave as a container to hold text, elements, attributes, media objects or mix of all. A DTD element is declared with an ELEMENT declaration. 

All DTD element declarations have this general form −

<!ELEMENT elementname (content)>

  • ELEMENT declaration is used to indicate the parser that you are about to define an element.
  • elementname is the element name (also called the generic identifier) that you are defining.
  • content defines what content (if any) can go within the element.

Content of elements declaration in a DTD can be categorized as below :

1. Empty Content

This is a special case of element declaration. This element declaration does not contain any content. These are declared with the keyword EMPTY.

Syntax:

<!ELEMENT elementname EMPTY >

2. Element Content

In element declaration with element content, the content would be allowable elements within parentheses. We can also include more than one element.

Syntax:

<!ELEMENT elementname (child1, child2...)>

3. Mixed Element Content

This is the combination of (#PCDATA) and children elements. PCDATA stands for parsed character data, that is, text that is not markup. Within mixed content models, text can appear by itself or it can be interspersed between elements. The rules for mixed content models are similar to the element content as discussed in the previous section.

Syntax:

<!ELEMENT elementname (#PCDATA|child1|child2)*>

4. ANY Element Content

You can declare an element using the ANY keyword in the content. It is most often referred to as mixed category element. ANY is useful when you have yet to decide the allowable contents of the element.

Syntax:

<!ELEMENT elementname ANY>

11.  What are the essential features of web browser? Explain.

5 marks view

Browsers are software programs that allow you to search and view the many different kinds of information that's available on the World Wide Web.

Essential Features of web browser:

1. The Web browser should be able to look at the Web pages throughout Internet or to connect to various sites to access information, explore resources and have fun.

2. The Web browser must enable you to follow the hyperlinks on a Web and type in a URL for it to follow.

3. Another feature of browser is to have a number of other commands readily available through menus, icons, and buttons.

4. Your browser ought to include an easy way to get on-line help as well as built in links to other resources on the Web that can give you helps or answer your questions.

5. One of the main feature of a browser is to search the information on the current page as well as search the WWW itself.

6. Browser give you the facility to save a Web page in a file on your com pull print a Web page on your computer, and send the contents of a Web page e-Mail to others on the Internet.

7. Few Web browser are complete Internet package, means they come with components like e-Mail client, newsgroup client an HTML composer, telnet client, ftp client, etc.

8. Web browser should be able to handle text, images of the World Wide Web, as well as the hyperlinks to digital video, or other types of information.

9. The most important feature of any browser is ease of use. While all Web browser  are fundamentally simple to use, the one you settle on should be very easy to work with; it should function as a transparent window onto the Web.

12.  Describe the significance of IP addresses and their types.

5 marks view

An Internet Protocol address (IP address) is a numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication. An IP address provides an identity to a networked device. Similar to a home or business address supplying that specific physical location with an identifiable address, devices on a network are differentiated from one another through IP addresses.

There are following types of II address. Private IP Address , Public IP Address , Static IP Address , Dynamic IP Address

Private IP Address:  A private IP address is an IP address which is communicate within the same network. Devices with a private IP address cannot to the internet directly. Likewise, computer or the other devices outside the local network cannot connect directly to a devices with a private IP address.

Public IP Address: A public IP address is an IP address which is used to communicate outside the network and each IP address is unique. The public IP address is assigned to the device by the internet service provider (ISP) as soon as the device is connected to the internet.

Static IP Address: A static IP address are those type of IP address that never change once they are assigned to a device on a network.

Dynamic IP Address: The dynamic IP address are those type of IP address that can change from time-to-time. These IP address are assigned to a device when they get connected to the internet each time.

13.  Differentiate between file handling and form handling.


5 marks view

File handling

File handling simply deal with creating, reading, deleting and editing files. Website can handle local files. It can read from, and write to, a text file on the disk. The code can run on any server with file system privileges—and also a local development machine
There are some methods of File which are used in PHP:

PHP Open File - fopen():
fopen() function opens the file. The first parameter of fopen() contains the name of the file to be opened and the second parameter specifies in which mode the file should be opened. E.g.
    $myfile = fopen("webdictionary.txt""r"

PHP Read File - fread():
The fread() function reads from an open file. The first parameter of fread() contains the name of the file to read from and the second parameter specifies the maximum number of bytes to read. The following PHP code reads the "webdictionary.txt" file to the end:
    fread($myfile,filesize("webdictionary.txt"));

PHP Close File - fclose():
The fclose() function is used to close an open file. E.g.
    fclose($myfile);

PHP Write to File - fwrite():
The fwrite() function is used to write to a file. The first parameter of fwrite() contains the name of the file to write to and the second parameter is the string to be written. E.g.
<?php
$myfile = fopen("newfile.txt""w"or die("Unable to open file!");
$txt = "Hello bro!\\n";
fwrite($myfile, $txt);
fclose($myfile);
?>

Form Handling

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";  

?>