068 WT

Ranjan Bajracharya
8 min readJan 24, 2018

old question solution

Web Server

A Web server is a program that uses HTTP (Hypertext Transfer Protocol) to serve the files that form Web pages to users, in response to their requests, which are forwarded by their computers’ HTTP clients. Dedicated computers and appliances may be referred to as Web servers as well.”Web server” can refer to hardware or software, or both of them working together.

  1. On the hardware side, a web server is a computer that stores web server software and a website’s component files (e.g. HTML documents, images, CSS stylesheets, and JavaScript files). It is connected to the Internet and supports physical data interchange with other devices connected to the web.
  2. On the software side, a web server includes several parts that control how web users access hosted files, at minimum an HTTP server.

A static web server, or stack, consists of a computer (hardware) with an HTTP server (software). We call it “static” because the server sends its hosted files “as-is” to your browser.

A dynamic web server consists of a static web server plus extra software, most commonly an application server and a database. We call it “dynamic” because the application server updates the hosted files before sending them to your browser via the HTTP server.

Internet as client/server technology

Client/server is a program relationship in which one program (the client) requests a service or resource from another program (the server). Internet is a networking platform to communicate between client and server computer. Client sends request to server which is carried through internet ,so internet carries request of the client. And after server receives this request it respond to accordingly. Again, the request is carried through internet. Since, internet works as client while carrying request and sever when carrying respond, Internet is a client/server technology.

What is a DTD?

A DTD is a Document Type Definition. A DTD defines the structure and the legal elements and attributes of an XML document.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.

If the DTD is declared inside the XML definition with the following syntax:
file , it should be wrapped in a DOCTYPE

<?xml version=”1.0"?>
<!DOCTYPE note [
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don’t forget me this weekend</body>
</note>

If the DTD is declared in an external file, the <!DOCTYPE> definition must contain a reference to the DTD file:

<?xml version=”1.0"?>
<!DOCTYPE note SYSTEM “note.dtd”>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don’t forget me this weekend!</body>
</note>

HTM document with the paragraph using <p>,
<h1>, <strong> for the first word for every sentence and <em> for all the capital letters.


<html>
<body>
<p><strong><em>HTML</em></strong> is the standard markup language for creating Web pages.<strong><em>HTML</em></strong>tags are element names surrounded by angle brackets:
<p>
</body>
</html>

DOM (Document Object Model)

Design DOM for the time table of your classes in the present semester.

<html>
<body>
<h2>Time Table</h2>
<table>
<tr>
<th>Days</th>
<th> 7:00-8:00</th>
<th> 8:00-9:00</th>
<th> 9:00-9:30</th>
<th> 9:30 -10:30</th>
</tr>
<tr>
<td id="first"></td>
<td id="SE"></td>
<td id="CDC"></td>
<td id="RTS"></td>
<td id="Ecom"></td>

</tr>
<tr>
<td id="first"></td>
<td id="SE"></td>
<td id="CDC"></td>
<td id="RTS"></td>
<td id="Ecom"></td>

</tr>

<table>
<script>
document.getElementById("first").innerHTML = "Monday";
document.getElementById("SE").innerHTML = "SE";
document.getElementById("CDC").innerHTML = "CDC";
document.getElementById("RTS").innerHTML = "RTS";
document.getElementById("Ecom").innerHTML = "Ecom";
</script>
</body>
</html>

Common application of web server

A web server’s main purpose is to store web site files and broadcast them over the internet for you site visitor’s to see. In essence, a web server is simply a powerful computer that stores and transmits data via the internet. When someone visits a web page on your site their browser communicates with your web server, sending and receiving information that ultimately dictates what appears on the visitor’s computer screen. Thus, the main purpose of a web server is to store and transfer web site data upon the request of a visitor’s browser.Without web servers the internet as we know it would cease to exist. Web servers are an integral part of the way the internet works.

Function of web caches

Caching is storing something temporarily for fast retrieval later on.Web Caching is storing of HTTP responses temporarily for fast retrieval later on.Web caching works by caching the HTTP responses for requests according to certain rules.Function of web caches:-

  • Decreased network costs:- When the content is cached closer to the consumer, requests will not cause much additional network activity beyond the cache.
  • Improved responsiveness: Caching enables content to be retrieved faster because an entire network round trip is not necessary.
  • Increased performance on the same hardware: For the server where the content originated, more performance can be squeezed from the same hardware by allowing aggressive caching.
  • Availability of content during network interruptions: With certain policies, caching can be used to serve content to end users even when it may be unavailable for short periods of time from the origin servers.

Headers in an HTTP message from a client

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.
  • Client Request-header: These header fields have applicability only for request messages.
  • Server 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.

Advantages of XML over the HTML

  • It is much simpler compare to HTML
  • XML documents can be Valid or Well Formed
  • Linking is very much simpler in XML than in SGML, but also much more intelligent than HTML
  • No longer restricted a limited set of tags, you can create your own set of tags.
  • XML is very powerful, yet easy to implement, not limited on data structures
  • It is in text format, Human readable and easy to edit
  • XML is universally compatible.
  • 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 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.

XSL is different from CSS

XSL is a language for expressing style sheets. An XSL style sheet is, like with CSS, a file that describes how to display an XML document of a given type.

  • XSL uses the XML notation that is helpful in writing the codes
  • XSL is having the formatting object tree setup differently from the source tree
  • XSL is not supported by many of the web browsers
  • It can convert data in a standard XML format to SQL statements

Format of XSL

<xsl:template pattern=”pattern”>
<formatting objects/>
</xsl:template>

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

XML provides an application independent way of sharing data. With a DTD, independent groups of people can agree to use a common DTD for interchanging data. An XML document with correct syntax is called “Well Formed”.An XML document validated against a DTD is both “Well Formed” and “Valid”.The purpose of a DTD is to define the structure of an XML document. It defines the structure with a list of legal elements:

<!DOCTYPE note
[
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
  • !DOCTYPE note defines that the root element of the document is note
  • !ELEMENT note defines that the note element must contain the elements: “to, from, heading, body”
  • !ELEMENT to defines the to element to be of type “#PCDATA”
  • !ELEMENT from defines the from element to be of type “#PCDATA”
  • !ELEMENT heading defines the heading element to be of type “#PCDATA”
  • !A”

Components of an XML file

  • 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”?>
  • 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.
  • 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.
  • Content:- Content refers to the information represented by the elements of an XML document. Consider the following example:
    <name>ram</name >
  • 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”>shanshak </ Student_name >

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

Differentiate between domain name and domain name system.

Domain Name:- A domain name could be a distinctive name that identifies an internet site.Whenever you visit an internet site, the name seems within the address bar of the online browser. Some domain names area unit preceded by “www” (which isn’t a part of the domain name), whereas others omit the “www” prefix. All domain names have a website suffix, such as .com, .net, or .org.

Domain Name System:- A domain name server (or name server) is a computer that houses DNS zones of domain names. This includes A (host) records, CNAME (aliases) records, and MX (mail exchange) records for domain names.It is the backend system that resolves domain names and IPs worldwide.It enables your website to be visible for people on Internet.

Form handling

Form elements are different types of input elements, like text fields, check boxes, radio buttons, submit buttons, and more.Forms are used to get input from the user and submit it to the web server for processing.

<html>
<head>
<script>
function validateForm() {
var x = document.forms["myForm"]["fname"].value;
if (x == "") {
alert("Name must be filled out");
return false;
}
}
</script>
</head>
<body>
<form name="myForm" action="/action_page.php"
onsubmit="return validateForm()" method="post">
Name: <input type="text" name="fname">
<input type="submit" value="Submit">
</form>
</body>
</html>

--

--

Ranjan Bajracharya

MSP 2017. Graduation in computer science and information technology. Studying MBA.