0% found this document useful (0 votes)
296 views25 pages

Web and Internet Technology Model Question Paper 6th Semester CSE

Uploaded by

equbalm71
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
296 views25 pages

Web and Internet Technology Model Question Paper 6th Semester CSE

Uploaded by

equbalm71
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Model Question Paper

Subject: Web and Internet Technology

Registration No.: ……………………

Course/Branch: B.Tech. / CSE Semester: VIth


Subject Name: Web and Internet Technology Max. Marks: 70
Subject Code: Time: 3 hours

Information for you:


1. This Examination paper contains total 7-Questions.
2. Question-1 is compulsory.
3. Attempt total Five Question.
Advice to you:
1. You should write your answers clearly in your own words.
2. Draw the figures and take examples if required.

1. Find the correct answer of the followings: (7 x 2 = 14)

a)What is the correct HTML tag for inserting a line break.


i)<lb>
ii)<br>
iii)<break>
iv)<newline>

b) What is the correct HTML tag for creating a hyperlink?


i)<link>
ii)<url>
iii)<a>
iv)<hlink>

c) Which DHTML technology does the following code utilize: document.write(Date())?


i)HTML
ii)CSS
iii)JavaScript
iv)None of these

d) XML is designed to ____ and ____ data.


i) design, style
ii)design, send
iii)store, style
iv)store, transport
e) In XML, DTD stands for ____.
i)Document Type Declaration
ii)Data Type Definition
iii)Document Type Definition
iv) Document To Declaration

f) Ajax is about updating ______, without reloading the full-page.


i)parts of a web page
ii)parts of a database records
iii)parts of a HTML tags dynamically
iv)parts of a CSS classes dynamically

g) PHP stands for –


i)Hypertext Preprocessor
ii)Pretext Hypertext Preprocessor
iii)Personal Home Processor
iv)None of the above

2)a) Explain different markup languages with examples. [7]


2)b) Explain Fat client and Fat server along with benifits and drawbacks. [7]

3)a) Which HTML tag is used to display the data in the tabular form? Give any example of creating
table and displaying data. [7]
3)b)What is CSS. How can you use an internal and external CSS. Explain with suitable examples. [7]

4)a) What is XML Schema. Explain creating element declarations in XML schema. [7]
4)b) Differentiate between XSD and DTD. [7]

5)a) What is JavaScript? Write a code to change color of a text using CSS with JavaScript in
DHTML. [7]
5)b Differentiate between SAX Parser and DOM Parser. [7]

6)a) Explain different events for the XMLHttpRequest Object. [7]


6)b) Explain XMLHttpRequest Object Methods and Properties. [7]

7) Write short notes on: (Any Two) [14]


a) AJAX
b) PHP
c) Active Server Page
Answers:
1) a) ii
1) b) iii
1) c) iii
1) d) iv
1) e) iii
1) f) i
1)g) i
2)a) Explain different markup languages with examples. [7]
Answer: Markup languages are computer languages that are used to structure, format, or define
relationships between different parts of text documents with the help of symbols or tags inserted in
the document. These languages are more readable than usual programming languages with strict
syntax. There are several markup languages available but the most popular among them are as
follows.

1. HTML
2. XML
3. SGML

1. HTML:

 Hypertext Markup Language (HTML) is a markup language used to create and link
webpages.
 It defines the basic structure of a web page and contains meta-data about the page and a
series of elements to be displayed on the web page.
 It uses predefined tags such as <table>, <form>, etc. to render different elements on the
webpage.
 Each element requires starting and ending tag with content inside it.
 Marked up document written in HTML is displayed by a web browser that interprets
different tags and accordingly formats and structures the content of the document before
displaying it.
 It can be written in a plain text editor and can be associated with styling sheets such
as CSS (Cascading Style Sheets) and scripting languages such as JavaScript.

Features:
1. Easy to learn
2. Platform-independent
3. Support audio, video, and images embedded web pages
4. Supported by all browsers
5. Can be integrated with styling and scripting languages

<!DOCTYPE html>

<html>

<head>

<title>HTML Example Code</title>


</head>

<body>

<h1>Web and Internet Technology</h1>

<p>A computer science portal for WIT</p>

</body>

</html>

Output:

Web and Internet Technology

A computer science portal for WIT

Drawbacks:
1. It can only create static web pages because of its static nature.
2. It offers limited security features.
3. It requires long code for creating even a simple web page.

2.XML:

 Extensible Markup Language (XML) is a markup language used for storing structured data.
 It uses custom tags to define the elements which support a wide range of elements.
 It was developed because HTML was unable to define new elements hence XML was
introduced which was extensible to define custom elements.
 It was designed to store and transport data and contain information about the sender,
receiver, heading, and message body.
 It is more focused on what data is rather than how data looks.
 It is used for representing documents, data, transactions, invoices, etc.
Features:
1. Efficient data sharing
2. Software and hardware independent
3. Compatible with other markup languages
4. Supports platform transition
5. Supports Unicode

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

<message>

<to>Users</to>

<from>Engineering</from>

<subject>Welcome message</subject>

<text>Welcome to CSE</text>

</message>
OUTPUT:

Message {4}
to: Users
from:Engineering</from>
subject:Welcome message</subject>
text:Welcome to CSE</text>

Drawbacks:
1. It is verbose in nature and has redundant syntax.
2. It has high storage and transportation cost.
3. It generally has large file sizes due to redundant syntax.

3.SGML:
 Standard Generalized Markup Language (SGML) is a markup language that provides a
standard for defining markup languages.
 It is used for marking up files such that they are no longer dependent on any other
application.
 It uses .sgml extension for saving SGML files. It manipulates massive files which require
frequent revisions and is a part of complicated systems.
 It defines the relationship between entities, elements, and attributes of a document and also
defines rules that allow the computer system to identify the start and end of an element.
 It provides the simplest way to exchange files between machines and applications directly.
Features:
1. Platform independent
2. Elements marked by different tags
3. Elements have generic types and attributes
4. Consistent use of delimiters and special characters
5. String substitution for standard boilerplate text, and document management

<MESSAGE>

<FROM>Engineering</FROM>

<TEXT>Welcome to CSE</TEXT>

</MESSAGE>

OUTPUT:

Message {2}

FROM:Engineering

TEXT:Welcome to CSE

Drawbacks:
1. It has a complex linking procedure.
2. It is very hard to write SGML code.

2)b) Explain Fat client and Fat server along with benifits and drawbacks. [7]
Answer: FAT CLIENT:

If the bulk of applications runs on client side then it is fat client. It is used for decision support and
personal software.A thick client (sometimes called a fat client) is a form of client-server architecture.
Specifically, it is a networked computer system with most resources installed locally, rather than
distributed over a network. Thick client devices can be, for example, PCs, because they have their
own hard drives, software applications and other local resources. Most, if not, all essential
components are contained in a thick client.

Thick clients are almost unanimously preferred by network users because they are very
customizable and the user has more control over what programs are installed and the specific
system configuration. Workplaces will commonly provide thick clients to employees so they can
work offline. With thick clients, there is no need to have continuous server communication.

Thick clients are connected to a server over a network connection but don't need to have a
maintained connection. The temporary connection is needed to download programs, data and updates
to the operating system. In addition, thick clients don't need to consume any server computing
resources. Most resources will be available on the client, so it can function independently. Thick
clients will excel in environments where the primary server has limited storage and computing
capacity, or experiences high network speeds, as well as in work-from-home environments.

Benefits and drawbacks of thick clients

Thick clients have a number of benefits to them, for example:

 Working offline. One of the biggest benefits of thick clients is the ability it gives to work offline.
Thick clients normally have the hardware and software requirements to work as needed, often
without needing to be connected to a central server.

 Server connection. Thick clients can work offline because they don't need to maintain constant
connections to central servers. Once an initial amount of information is gathered from a server,
server connections are generally not needed.

 Fewer server requirements. The servers that thick clients connect to don't need to be as high-
performing. Since the thick clients do a lot of the application processing, that can allow for
cheaper servers.

 Server capacity. The use of thick clients normally means more server capacity is available. With
fewer requirements that a server has to provide to each individual client, the server can benefit
more clients.
 More flexibility. Having a computer that works off of its own local resources -- operating
system, user interface, storage -- means a large level of flexibility. They should be able to work
from wherever, as long as they are able to have a momentary connection to a central server to
download any needed data.

 Existing infrastructure. In the same line of thought, many organizations may already have fast
enough local PCs to implement an infrastructure to run thick clients with relative ease.

 Storage. Files and applications can be stored on the thick client, meaning they can be accessed at
any time.

 Computer performance. Any application that would be resource or bandwidth-intensive should


be able to perform well since resources are being taken from the individual computers and not
being allocated by a central server.

Thick clients are not free from their downsides, however, including:

 Security. The individual will now have to be more responsible for the security and protection of
their computer, since data will be stored on the thick client.

 Data storage. Data storage can be a double-edged sword as data now needs to be backed up in
order to ensure the data isn't gone forever if something goes wrong.

 Investment into each client. The hardware and software will have a higher up-front cost, and
will then have a continual cost in maintenance and updates.

 Maintenance. May include updates for security or any hardware and software fixes across the
connected clients.

 Network traffic. There can be a lot of network traffic since each client needs to bring data
through a network to work on locally.

 New applications. New applications that a client may need may also have to be uploaded on
other workstations.
FAT SERVER:

If the bulk of application runs on server side, then it is fat servers. It tries to minimize network
interchanges by creating more abstract levels of services.

A fat server provides most of the functionality a client machine within a client/server computing
architecture requires. Think of it as a standard core server that hosts and provides critical network-
based applications and storage, processing, Internet access, and other services.
In much simpler terms, in a network comprising a fat server and multiple computers, none of the
processing is done by any of the connected computers. Instead, all the processing happens on the fat
server.

The client in the fat server model provides the GUI and interacts with the server through remote
procedure calls (or method invocations)

These are used for mission-critical applications, represent the new growth area fro PC-based
client/server computing.

Benefits:

 The server costs less because it doesn’t need a lot of resources.


 Fat Server applications are easier to manage and deploy on the network because most of the
code runs on the servers.
 Fat servers try to minimize network interchanges by creating more abstract levels of service.
 Transaction and object servers, for example, encapsulate the database.

 The activities a user performs on a client will have very little effect on how other clients

perform.

Drawbacks:

 Each client needs to pass data over the network, increasing data traffic volumes. That can be

negligible in a modern office network but can be problematic when done over the Internet or

across multiple physical locations.

 Only the clients with the appropriate applications can connect to the server.

3)a) Which HTML tag is used to display the data in the tabular form? Give any example of
creating table and displaying data. [7]

Answer: The HTML table tag is used to display data in tabular form (row * column). It also manages
the layout of the page, e.g., header section, navigation bar, body content, footer section. Here is the
list of tags used while displaying the data in the tabular form:

Tag Description

<table> It defines a table.

<tr> It defines a row in a table.

<th> It defines a header cell in a table.

<td> It defines a cell in a table.


<caption> It defines the table caption.

<colgroup> It specifies a group of one or more columns in a table for formatting.

<col> It is used with <colgroup> element to specify column properties for each column.

<tbody> It is used to group the body content in a table.

<thead> It is used to group the header content in a table.

<tfooter> It is used to group the footer content in a table.

Example of creating table and displaying data is:


<table border="1">
<tr>
<td>Row 1</td>
<td>Row 2</td>
<td>Row 3</td>
</tr>
<tr>
<td>Row 1</td>
<td>Row 2</td>
<td>Row 3</td>
</tr>
</table>
Output:

3)b)What is CSS. How can you use an internal and external CSS. Explain with suitable
examples. [7]

Answer: CSS is the language we use to style a Web page.

 CSS stands for Cascading Style Sheets


 CSS describes how HTML elements are to be displayed on screen, paper, or in other media
 CSS saves a lot of work. It can control the layout of multiple web pages all at once
 External stylesheets are stored in CSS files

Internal CSS: Internal CSS, also known as embedded CSS is a method of adding CSS rules
directly to the head section of an HTML document. It involves using the <style> element to
enclose the CSS code within the HTML document itself. Internal CSS is placed within
the <head> section of the HTML document, typically after the document’s title and before any
other content.
Syntax:
<style>
// CSS Properties
</style>
Example:
<!DOCTYPE html>
<html>

<head>
<title>
Internal CSS
</title>

<style>
h1 {
color: blue;
font-size: 24px;
font-weight: bold;
}

p{
color: green;
font-size: 16px;
}
</style>
</head>

<body>
<h1>WelCome</h1>
<p>WelCome</p>
</body>

</html>

Output: In this example, the <style> element is used to enclose the CSS rules that apply to the h1
and p elements. Any styling applied with internal CSS is specific to that HTML document and
cannot be used on other pages or websites.

WelCome
WelCome

External CSS: External CSS is used to place CSS code in a separate file and link to the HTML
document. To use external CSS, create a separate file with the .css file extension that contains your
CSS rules. You can link this file to your HTML document using the “link” tag in the head section
of your HTML document.
Syntax:
<head>
<link rel="stylesheet"
type="text/css" href="style.css">
</head>
In this case, the “link” tag specifies the type of the file (CSS), the relationship between the HTML
document and the CSS file (“stylesheet”), and the location of the CSS file (“href” attribute). The
href attribute points to the URL or file path of your external CSS file.
Example: HTML code:
<!DOCTYPE html>
<html>

<head>
<title>External Style</title>
<link rel="stylesheet"
type="text/css" href="style.css">
</head>

<body>
<h1>WelCome</h1>
<p>WelCome</p>
</body>

</html>

Create a CSS file named styles.css and write all the codes in that CSS file
File name: style.css
h1 {
color: blue;
font-size: 24px;
font-weight: bold;
}

p{
color: green;
font-size: 16px;
}
Output:

WelCome
WelCome

4)a) What is XML Schema. Explain creating element declarations in XML schema.
[7]
Answer:
 XML Schema is commonly known as XML Schema Definition (XSD).
 It is used to describe and validate the structure and the content of XML data.
 XML schema defines the elements, attributes and data types.
 Schema element supports Namespaces.
 It is similar to a database schema that describes the data in a database.
 An XML Schema describes the structure of an XML document, just like a DTD.
 An XML document with correct syntax is called "Well Formed".
 An XML document validated against an XML Schema is both "Well Formed" and "Valid".

Importance of of XML schemas are as follows:

 They support data types, making it easier to validate data correctness, define data facets and
restrictions and convert data between different data types.

 They are written in XML, making them easier to extend and edit.

 Schemas allow the use of XML Parser to parse files, document modification with XML document
object model (DOM) and transformation with Extensible Stylesheet Language Transformations
(XSLT).

 Schemas help create a common language for XML content, allowing senders to describe
information (e.g., date) in ways that all receivers will understand so that the data is maintained
consistently.

Creating element declarations in XML schema

One of the functions of a schema is to indicate which elements can be used in an XML document,
where they should appear, and how many times they can be used. All of this information is included
in an element declaration. There are two types of elements we can declare in an XML
Schema: complex elements and simple elements.

Simple elements

A simple element is an XML element that can contain only data - it can’t contain child elements
or attributes.

The following example shows one method for creating simple elements:

<xs:element name="animal" type="xs:string" />

Data types for XML Schema Definition


Data type Contents
xs:string Text, or numbers that should be processed as text
xs:decimal Numeric value that contains a decimal
xs:integer Numeric value that does not contain a decimal point
xs:boolean Used to specify a true or false value
xs:date Used to specify a date in the form of YYYY-MM-DD (year, month, day)
xs:time Used to specify time in the form of hh:mm:ss (hours, minutes seconds)
Complex elements

Where simple elements only contain data, complex elements can hold much more. Complex elements
can contain attributes, child elements, and additional indicators that focus on the order of child
elements and how often they can occur. Example of a complex element:
<xs:element name="book">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string" />
<xs:element name="author" type="xs:string" />
<xs:element name="isbn" type="xs:integer" />
<xs:element name="genre" type ="xs:string" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>

</xs:element>
Description of order indicators that can be used in a complex element declaration
Order indicator Description
All Child elements can appear in any order; elements can appear 0 or 1 time
Choice Only one child element from the list can appear
Sequence Child elements must appear in the order they are listed

4)b) Differentiate between XSD and DTD.


[7]
Answer: XML Schema Definition
XSD stands for XML Schema Definition and it is a way to describe the structure of a XML
document. It defines the rules for all the attributes and elements in a XML document. It can also be
used to generate the XML documents. It also checks the vocabulary of the document. It doesn’t
require processing by a parser. XSD checks for the correctness of the structure of the XML file.
XSD was first published in 2001 and after that it was published in 2004.

Document Type Definition


DTD stands for Document Type Definition and it is a document which defines the structure of an
XML document. It is used to describe the attributes of XML language precisely. It can be classified
into two types namely internal DTD and external DTD. It can be specified inside a document or
outside a document. DTD mainly checks the grammar and validity of a XML document. It checks
that a XML document has a valid structure or not.
Difference between Document Type Definition (DTD) and XML Schema Definition (XSD)
S.NO. DTD XSD

DTD are the declarations that define a XSD describes the elements in a XML
1.
document type for SGML. document.

2. It doesn’t support namespace. It supports namespace.


S.NO. DTD XSD

3. It is comparatively harder than XSD. It is relatively more simpler than DTD.

4. It doesn’t support datatypes. It supports datatypes.

5. SGML syntax is used for DTD. XML is used for writing XSD.

6. It is not extensible in nature. It is extensible in nature.

It doesn’t give us much control on It gives us more control on structure of XML


7.
structure of XML document. document.

Any element which is made global can be


8. It specifies only the root element.
done as root as markup validation.

It doesn’t have any restrictions on data


9. It specifies certain data restrictions.
used.

10. It is not much easy to learn . It is simple in learning.

11. File here is saved as .dtd File in XSD is saved as .xsd file.

12. It is not a strongly typed mechanism. It is a strongly typed mechanism.

It uses #PCDATA which is a string data


13. It uses fundamental and primitive data types.
type.

5)a) What is JavaScript? Write a code to change color of a text using CSS with JavaScript in
DHTML. [7]
Answer:
 JavaScript is a lightweight, cross-platform, single-threaded, and interpreted
compiled programming language.
 It is also known as the scripting language for webpages. It is well-known for the
development of web pages, and many non-browser environments also use it.
 JavaScript is a weakly typed language (dynamically typed).
 JavaScript can be used for Client-side developments as well as Server-side developments.
 JavaScript can be included in HTML pages, which creates the content of the page as
dynamic.
 We can easily type the JavaScript code within the <head> or <body> tag of a HTML page.
 If we want to add the external source file of JavaScript, we can easily add using the <src>
attribute.
Code to change color of a text using CSS with JavaScript in DHTML:
<html>
<head>
<title>
getElementById.style.property example
</title>
</head>
<body>
<p id="demo"> This text changes color when click on the following different buttons. </p>
<button onclick="change_Color('green');"> Green </button>
<button onclick="change_Color('blue');"> Blue </button>
<script type="text/javascript">
function change_Color(newColor) {
var element = document.getElementById('demo').style.color = newColor;
}
</script>
</body>
</html>
Output:

In the above code, color of a text is changed by using the following syntax:

document.getElementById('demo').style.property=new_value;

The above syntax is used in the JavaScript function, which is performed or called when we clicked on
the HTML buttons. The different HTML buttons specify the color of a text..
5)b) Differentiate between SAX Parser and DOM Parser. [7]
Answer: Difference Between SAX Parser and DOM Parser:
There are two types of XML parsers namely Simple API for XML and Document Object Model.
 SAX
 DOM
SAX (Simple API for XML), is the most widely adopted API for XML in Java and is considered
the de-facto standard. Although it started as a library exclusive to Java, it is now a well-known API
distributed over a variety of programming languages. It is an open-source project and has recently
switched to SourceForge project infrastructure that makes it easier to track open SAX issues outside
the high-volume XML-dev list. The current latest version as of 01/10/2018 is SAX 2.0. It uses an
event-driven serial-access mechanism for accessing XML documents and is frequently used by
applets that need to access XML documents because it is the fastest and least memory-consuming
API available for parsing XML documents. The mechanism SAX uses makes it independent of the
elements that came before, i.e. it is state-independent.

DOM stands for Document Object Model. The DOM API provides the classes to read and write
an XML file. DOM reads an entire document. It is useful when reading small to medium size XML
files. It is a tree-based parser and a little slow when compared to SAX and occupies more space
when loaded into memory. We can insert and delete nodes using the DOM API.

SAX Parser
SAX represents a simple API for XML and a SAX API is implemented by SAX Parser. This API
was called event-based API which provides interfaces on handlers. There are four handler
interfaces. ContentHandler, DTDHandler, EntityResolver, and ErrorHandler interface. It
does not create any internal structure rather it takes the occurrences of components of an
input document as events, and then it tells the client what it reads as it reads through the
input document. It is suitable for large XML files because it doesn’t require loading the
whole XML file.
Features Of SAX Parser
 The internal structure can not be created by SAX Parser.
 These event-based SAX parsers work the same as the event handler in Java.
Advantages Of SAX Parser
 Very simple to use and has good efficiency of memory.
 Its runtime is too fast and it can work for a bigger document or file system.
Disadvantages Of SAX Parser
 Its ability to understand APIs is too less than an event-based API.
 We can’t know the full information because of a lot of pieces of data.
DOM Parser
DOM represents the Document Object model. When an object contains some information about
XML documents, is called DOM Parser. This looks like a tree structure. DOM API is
implemented by a DOM Parser, which is very easy and simple to use. It represents an XML
Document into tree format in which each element represents tree branches and creates an In
Memory tree representation of XML file and then parses it more memory is required for this.
Features Of DOM Parser
 The internal structure can be created by DOM Parser.
 Because of these internal structures, the client can get information about the original XML
docs.
Advantages Of DOM Parser
 DOM API is easy to use so that we can do both write and read operations.
 When a document is required then it preferred a wide part that can be randomly accessed.
Disadvantages Of DOM Parser
 Its efficiency of memory is not too good, it takes more memory cause XML docs needed to load
in there.
 In comparison to the SAX parser, it is too slow.

SAX Parser DOM Parser

It is called a Simple API for XML Parsing. It is called as Document Object Model.

It’s an event-based parser. It stays in a tree structure.

SAX Parser is slower than DOM Parser. DOM Parser is faster than SAX Parser.

Best for the larger sizes of files. Best for the smaller size of files.

It is not good at making XML files in low


It is suitable for making XML files in Java.
memory.

The internal structure can not be created by The internal structure can be created by DOM
SAX Parser. Parser.

It is read-only. It can insert or delete nodes.

In the SAX parser backward navigation is not In DOM parser backward and forward search is
possible. possible

Suitable for efficient memory. Suitable for large XML document.

A small part of the XML file is only loaded in


It loads whole XML documents in memory.
memory.

6)a) Explain different events for the XMLHttpRequest Object. [7]


Answer: Different events for the XMLHttpRequest Object are:
1) abort

Fired when a request has been aborted, for example because the program
called XMLHttpRequest.abort(). Also available via the onabort event handler property.

2) error
Fired when the request encountered an error. Also available via the onerror event handler
property.

3) load

Fired when an XMLHttpRequest transaction completes successfully. Also available via


the onload event handler property.

4) loadend

Fired when a request has completed, whether successfully (after load) or unsuccessfully
(after abort or error). Also available via the onloadend event handler property.

5) loadstart

Fired when a request has started to load data. Also available via the onloadstart event handler
property.

6) progress

Fired periodically when a request receives more data. Also available via the onprogress event
handler property.

7) readystatechange

Fired whenever the readyState property changes. Also available via


the onreadystatechange event handler property.

8) timeout

Fired when progress is terminated due to preset time expiring. Also available via
the ontimeout event handler property.

6)b) Explain XMLHttpRequest Object Methods and Properties. [7]


Answer: The XMLHttpRequest Object

The XMLHttpRequest object is used to exchange data with a server behind the scenes.

The XMLHttpRequest object is the developers dream, because you can:

 Update a web page without reloading the page


 Request data from a server after the page has loaded
 Receive data from a server after the page has loaded
 Send data to a server in the background

XMLHttpRequest Object Methods

Method Description
abort() Cancels the current request

getAllResponseHeaders() Returns header information

getResponseHeader() Returns specific header information

open(method,url,async,uname,pswd) Specifies the type of request, the URL, if the request should be
handled asynchronously or not, and other optional attributes of a
request

method: the type of request: GET or POST


url: the location of the file on the server
async: true (asynchronous) or false (synchronous)

send(string) send(string) Sends the request off to the server.

string: Only used for POST requests

setRequestHeader() Adds a label/value pair to the header to be sent

XMLHttpRequest Object Properties

Property Description

Onreadystatechange Stores a function (or the name of a function) to be called automatically each time the
readyState property changes
readyState Holds the status of the XMLHttpRequest. Changes from 0 to 4:
0: request not initialized
1: server connection established
2: request received
3: processing request
4: request finished and response is ready

responseText Returns the response data as a string

Returns the response data as XML data

responseXML

Status Returns the status-number (e.g. "404" for "Not Found" or "200" for "OK")

statusText Returns the status-text (e.g. "Not Found" or "OK")

7) Write Short Notes on(Any Two) [14]


Answers:
a) AJAX
 AJAX is Asynchronous JavaScript and XML.
 AJAX is a technique for creating fast and dynamic web pages.
 AJAX is not a programming language
 AJAX allows web pages to be updated asynchronously by exchanging small amounts of data
with the server behind the scenes. This means that it is possible to update parts of a web page,
without reloading the whole page.
 Classic web pages, (which do not use AJAX) must reload the entire page if the content should
change.
 Request data from a server - after the page has loaded
 Receive data from a server - after the page has loaded
 Send data to a server - in the background
 Examples of applications using AJAX: Google Maps, Gmail, Youtube, and Facebook tabs.

Working of AJAX:
AJAX is based on internet standards, and uses a combination of:

 XMLHttpRequest object (to exchange data asynchronously with a server)


 JavaScript/DOM (to display/interact with the information)
 CSS (to style the data)
 XML (often used as the format for transferring data)

The keystone of AJAX is the XMLHttpRequest object.

The XMLHttpRequest Object

 All modern browsers support the XMLHttpRequest object.


 The XMLHttpRequest object can be used to exchange data with a server behind the scenes.
This means that it is possible to update parts of a web page, without reloading the whole page.

Syntax for creating an XMLHttpRequest object:

variable = new XMLHttpRequest();

AJAX Example: To change the text.

<!DOCTYPE html>
<html>
<body>

<div id="demo">
<h1>The XMLHttpRequest Object</h1>
<button type="button" onclick="loadDoc()">Change Content</button>
</div>

<script>
function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML =
this.responseText;
}
};
xhttp.open("GET", "ajax_info.txt", true);
xhttp.send();
}
</script>

</body>
</html>

The "ajax_info.txt" file used in the example above, is a simple text file given
below:

<h1>AJAX</h1>
<p>AJAX is not a programming language.</p>
<p>AJAX is a technique for accessing web servers from a web page.</p>
<p>AJAX stands for Asynchronous JavaScript And XML.</p>

OUTPUT:

On clicking change Content Output is:


AJAX
AJAX is not a programming language.

AJAX is a technique for accessing web servers from a web page.

AJAX stands for Asynchronous JavaScript And XML.

b)PHP
 PHP is a self-referentially acronym for PHP: Hypertext Preprocessor.
 Original it supposedly meant personal home page.
 It is an open source, server-side, HTML embedded scripting language used to create dynamic
and interactive Web pages.
 PHP code is executed on the server.
 In an HTML document, PHP script (similar syntax to that of Perl or C) is enclosed within
special PHP tags.
 Because PHP is embedded within tags, the author can jump between HTML and PHP (similar
to ASP and Cold Fusion) instead of having to rely on heavy amounts of code to output
HTML. And, because PHP is executed on the server, the client cannot view the PHP code.
 PHP can perform any task that any CGI program can do, but its strength lies in its
compatibility with many types of databases.
 Also, PHP can talk across networks using IMAP, SNMP, NNTP, POP3, or HTTP.
 PHP.net :The PHP Web site for PHP development.
 PHP runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
 PHP is compatible with almost all servers used today (Apache, IIS, etc.)
 PHP supports a wide range of databases
 PHP is easy to learn and runs efficiently on the server side

PHP File:
 PHP files can contain text, HTML, CSS, JavaScript, and PHP code
 PHP code is executed on the server, and the result is returned to the browser as plain HTML
 PHP files have extension ".php"

PHP Uses:

 PHP can generate dynamic page content


 PHP can create, open, read, write, delete, and close files on the server
 PHP can collect form data
 PHP can send and receive cookies
 PHP can add, delete, modify data in your database
 PHP can be used to control user-access
 PHP can encrypt data.
 With PHP you are not limited to output HTML. You can output images or PDF files. You can
also output any text, such as XHTML and XML.

Basic PHP Syntax

 A PHP script can be placed anywhere in the document.

 A PHP script starts with <?php and ends with ?>:

<?php
// PHP code
?>

 PHP file normally contains HTML tags, and some PHP scripting code.
 PHP statements end with a semicolon (;).

An example of a simple PHP file, with a PHP script that uses a built-in PHP function "echo" to output
the text "Hello World!" on a web page:

<!DOCTYPE html>
<html>
<body>

<h1>My first PHP page</h1>


<?php
echo "Hello World!";
?>

</body>
</html>

OUTPUT:

My first PHP page


Hello World!

c) Active Server Page


ASP stands for active server pages and it is a server-side script engine for building web pages. ASP
is basically a server page that contains embedded programs in it. The programs in it are processed
on the Microsoft server. The ASP server-side engine basically performs the task of reading and
executing the ASP file and then return the file to the browser. It is basically a web-based framework
that helps programmers to build dynamic web pages. ASP can contain scripts as well as standard
HTML.
Example:
<html>
<head>
<title>ASP page</title>
</head>
<body>
<% response.write("Welcome") %>
</body>
</html>
Output
Welcome
Characteristics:
 User Control: The creation of user controls supports the making of reusable components.
 Custom Controls: We can make custom controls from ASP. Here the code is compiled into a
Dynamic Link Library file.
 Rendering Techniques: ASP uses visited composite rendering technique in which composite
tree is built.
 Code-Behind Model: Microsoft recommends to use the code-behind model for dealing with
dynamic program code.
Use of ASP: ASP is mainly used because of its high speed, language-independent nature, and low
cost. We can make ASP pages in any language so it is not dependent on a particular language. It is
used to develop dynamic websites in a more efficient way.
Advantages:
 ASP reduces the line of code for building the complex applications.
 It has smart caching technologies.
 ASP is language independent so any language can be used for coding it.
 ASP is much faster than other applications.
 ASP is more used now-a-days.
Disadvantages:
 There is a lot of complexity in pages and there are many performance issues.
 It is dependent on IIS(Internet information services) so it is problematic.
 It has limited development and debugging tools.
 There is no real state management in ASP.
--------------------------------------------------*---------------------------------------------------------------

You might also like