You are on page 1of 13

Internal Assignment

NAME: M BABAR

ROLL NUMBER: 0000

PROGRAM: MASTER OF COMPUTER APPLICATION (MCA)

SEMESTER: II

COURSE NAME: WEB TECHNOLOGIES

CODE:

SESSION: MAY 2023


Set – I

Q1.

a) Define TCP and IP communication through suitable diagram.


 TCP/IP (Transmission Control Protocol/Internet Protocol) is a set of protocols that form the
foundation for communication on the internet. It is a combination of two distinct protocols, TCP and
IP, that work together to enable reliable and efficient data transmission over networks.
TCP (Transmission Control Protocol) is responsible for establishing and maintaining a reliable
connection between two devices. It ensures that data packets are delivered in the correct order and
without errors. TCP provides features such as flow control, error detection, and congestion control.
IP (Internet Protocol) is responsible for the addressing and routing of data packets across the internet.
It defines how data packets are encapsulated, addressed, and transmitted from one network to another.
IP provides the fundamental addressing mechanism using IP addresses, allowing devices to be
identified and located on a network.

Here’s a simplified diagram illustrating the TCP/IP communication process-

+------------------------+ +-----------------------+
| Sender | | Receiver |
+------------------------+ +-----------------------+
| |
Application Layer Application Layer
| |
+------------------------+------------------------+
| TCP | TCP |
+------------------------+------------------------+
| IP | IP |
+------------------------+------------------------+
| Network | Network |
+------------------------+------------------------+
| Link/Physical | Link/Physical |
+------------------------+------------------------+
b) Why are Logical Character Tags used? Explain any five Logical Character Tags with
suitable example.
 Logical character tags are used to provide additional semantic information about specific characters or
sequences of characters within a text. These tags help in specifying the role or meaning of the tagged

characters, which can be beneficial for various applications such as natural language processing, text
analysis, and machine learning.
Five commonly used logical characters are as follow –
1. Part-of-Speech (POS) Tag: POS tags represent the grammatical category or syntactic role of a
word in a sentence. They help in identifying nouns, verbs, adjectives, adverbs, etc. Example: In
the sentence "The cat is sleeping," the POS tags could be "DT" (determiner) for "The," "NN"
(noun) for "cat," "VBZ" (verb) for "is," and "VBG" (verb, gerund or present participle) for
"sleeping."
2. Named Entity Tag: Named entity tags identify proper names, such as person names, locations,
organizations, dates, and other named entities in a text. Example: In the sentence "John works at Apple Inc.
in California," the named entity tags could be "PERSON" for "John," "ORG" for "Apple Inc.," and
"LOCATION" for "California."
3. Sentiment Tag: Sentiment tags indicate the emotional polarity or sentiment expressed by a word
or phrase. They can be used to determine whether a text conveys a positive, negative, or neutral
sentiment. Example: In the sentence "I love this movie; it's fantastic," the sentiment tag for "love"
could be "POS" (positive) and for "fantastic" it could be "POS" as well.
4. Emotion Tag: Emotion tags capture the emotional content or sentiment associated with a word or
expression. They can represent emotions such as happiness, sadness, anger, surprise, etc.
Example: In the sentence "I'm so excited to see you!", the emotion tag for "excited" could be
"HAPPY."
5. Punctuation Tag: Punctuation tags represent various punctuation marks used in a text. They help
in identifying and distinguishing different types of punctuation, such as periods, commas,
question marks, exclamation marks, etc. Example: In the sentence "Where are you going?", the
punctuation tag for "?" could be "QUESTION_MARK."

Q2.

a) What is DHTML? What are the advantages of DHTML?


 Dynamic HTML refers to a combination of technologies used to create interactive and dynamic web
pages. It combines HTML (Hypertext Markup Language), CSS (Cascading Style Sheets), and
JavaScript to enhance the functionality and interactivity of web content.
Advantages of DHTML are:
1. Enhanced User Experience: DHTML allows web developers to create engaging and interactive
user experiences by enabling dynamic content updates and animations. Elements on a web page
can be manipulated in real-time, providing a more dynamic and responsive interface for users.
2. Reduced Server Load: With DHTML, many tasks that previously required server-side
processing can be performed on the client side. This reduces the need for frequent server requests,
resulting in faster page loading times and reduced server load.

3. Improved Interactivity: DHTML enables developers to create interactive elements such as


dropdown menus, sliders, image carousels, and tooltips. These interactive features enhance the
user interface and make websites more intuitive and user-friendly.
4. Dynamic Content Updates: DHTML allows for the modification of content on the fly without
requiring a full page reload. This enables developers to update specific sections of a web page
dynamically, resulting in a more seamless and efficient user experience.
5. Cross-Browser Compatibility: DHTML technologies, such as CSS and JavaScript, are
supported by modern web browsers, ensuring cross-browser compatibility. This means that
DHTML-powered web pages can be accessed and enjoyed by a wide range of users regardless of
their browser preferences.
6. Easy Maintenance and Updates: DHTML separates the structure (HTML), presentation (CSS),
and behavior (JavaScript) of a web page, making it easier to maintain and update. Changes can be
made to specific sections of the code without affecting the entire page, simplifying maintenance
and reducing the risk of introducing errors.
7. Integration with Existing Web Technologies: DHTML seamlessly integrates with other web
technologies, such as server-side scripting languages (e.g., PHP, ASP), databases, and APIs. This
allows developers to build dynamic web applications that interact with back-end systems and
retrieve data in real-time.
b) What are the building blocks of an XML document? Explain with example.
 The building block of an XML document are as follow –
1. Tags: Tags are the fundamental building blocks of XML. They enclose elements and define the
structure and hierarchy of the document. Tags are represented by angle brackets (< and >) and
come <book> </book>
in pairs: start tags and end tags. For example, is a start tag, and is the
corresponding end tag.
2. Elements: Elements are defined by the opening and closing tags and represent the basic units of
data in an XML document. They can contain other elements, text, or both. For example:
<book>
<title>Harry Potter and the Sorcerer's Stone</title>
<author>J.K. Rowling</author>
</book>
3. Attributes: Attributes provide additional information about elements. They consist of a name-
value pair and are specified within the opening tag of an element. For example:

<book category="fantasy">
<title>Harry Potter and the Sorcerer's Stone</title>
<author>J.K. Rowling</author>
</book>

4. Text: Text refers to the actual content within an element. It can be plain text or data. For example,
in the following XML snippet, "Harry Potter and the Sorcerer's Stone" and "J.K. Rowling" are
the text content within the <title> and <author> elements, respectively:

<book>
<title>Harry Potter and the Sorcerer's Stone</title>
<author>J.K. Rowling</author>
</book>

5. Comments: Comments provide explanatory or informative notes within an XML document. They
are enclosed in <!-- -->
and and are not processed by XML parsers. Comments are useful for
adding human-readable descriptions or for temporarily disabling parts of the document.
<!-- This is a comment -->
<book>
<!-- This element represents a book -->
<title>Harry Potter and the Sorcerer's Stone</title>
<author>J.K. Rowling</author>
</book>

Q3.

a) Explain about XPointer in details.


 XPointer is a component of the XML Linking Language (XLink) that provides a mechanism for
addressing specific parts or fragments within an XML document. It allows you to create pointers or
references to specific locations or elements within an XML document, enabling more precise linking
and referencing capabilities.
XPointer supports various addressing schemes, each with its syntax and rules for specifying the target
location. Here are some commonly used XPointer addressing schemes:
1. XPath-based XPointer:
 XPath-based XPointer uses XPath expressions to identify specific elements or nodes
within an XML document.
 XPath is a language for navigating XML documents and selecting nodes based on their
location or properties.
 An XPath expression within an XPointer can target elements, attributes, text nodes, or any
other nodes within the XML document.
2. Element ID-based XPointer:
 Element ID-based XPointer utilizes the unique identifier (ID) attribute of an element to
address specific elements.
 An ID is a unique identifier assigned to an element using the XML attribute "id". It allows
for efficient and direct identification of elements.

 With an element ID-based XPointer, you can reference an element by specifying its ID
value.
3. Range- based XPointer:
 Range-based XPointer allows you to specify a range or selection of nodes within an XML
document.
 It is used to address a portion of the document between two anchor points, such as start
and end tags or character positions.
 Range-based XPointer is particularly useful for addressing specific sections of long
documents or fragments within elements.
4. Media-based XPointer:
 Media-based XPointer is used to address specific parts within non-XML resources
embedded within an XML document, such as images, audio, video, etc.
 It relies on media-specific addressing schemes to specify the desired location or fragment
within the media resource.
 Media-based XPointer can be used to link to or reference specific portions of multimedia
content contained within an XML document.
b) Explain the concept of XSLT?
 XSLT (Extensible Stylesheet Language Transformations) is a powerful language and technology used
for transforming XML documents into various formats, such as HTML, XML, plain text, or even
other XML structures. It is a key component of the broader XSL (Extensible Stylesheet Language)
family of standards.
Transformation process of XSLT –
1. XML Input Document:
 XSLT begins with an XML input document that serves as the source of data to be
transformed.
 The XML input document contains the data and structure that will be processed by the
XSLT transformation.
2. XSLT Stylesheet:
 An XSLT stylesheet is created separately from the XML input document.
 The stylesheet defines a set of rules, called templates, that dictate how the input document
should be transformed.
 The stylesheet includes instructions on how to select elements or nodes, manipulate their
content, and generate the desired output.
3. Processing Model:
 XSLT uses a processing model based on the concept of matching templates.
 Templates are defined in the XSLT stylesheet and specify patterns for matching specific
elements or nodes in the XML input document.
 When a template matches an element or node during the transformation, its associated
instructions are executed.
4. Template Execution:
 During the transformation process, XSLT applies the templates defined in the stylesheet to
the XML input document.
 Templates are executed in a recursive manner, starting from the root node and traversing
the XML document's hierarchy.
 When a template matches an element or node, the instructions within that template are
executed to produce the desired output.
5. Output Generation:
 As the templates are executed, XSLT generates the transformed output based on the
defined rules and instructions.
 The output can be in various formats, such as HTML, XML, or plain text, depending on
the requirements specified in the XSLT stylesheet.
6. Transformation Result:
 The final result of the XSLT transformation process is the transformed output document.
 The output document reflects the structure and content defined by the XSLT stylesheet
and the rules applied during the transformation.

Set – II
Q4.
a) How does AJAX work? Explain with example.
 AJAX, which stands for Asynchronous JavaScript and XML, is a technique used in web development
to create interactive and dynamic web pages. It allows web browsers to send and receive data from a
web server asynchronously without requiring the entire page to reload.
Working of AJAX is as follow –
1. Event Trigger: AJAX is typically triggered by an event on a web page, such as a button click or
a form submission.
2. JavaScript Request: When the event occurs, JavaScript code is executed to initiate an AJAX
request.
3. XMLHttpRequest Object: The XMLHttpRequest object is created by JavaScript to handle the
AJAX request. This object provides methods and properties to send and receive data from a server
without refreshing the entire page.

4. Data Sending: The XMLHttpRequest object sends a request to the server, including any data that
needs to be sent, such as form inputs or query parameters. This data is usually encoded in a format
like URL-encoded parameters or JSON.
5. Server Processing: The server receives the AJAX request, processes the data if necessary, and
generates a response.
6. Data Retrieval: The XMLHttpRequest object asynchronously retrieves the server's response
without reloading the entire page. This response can be in various formats, including HTML,
XML, JSON, or plain text.
7. Client-side Manipulation: Once the response is received, JavaScript code on the client-side can
manipulate the page's DOM (Document Object Model) to update the content dynamically. It can
add, remove, or modify elements on the page based on the data received.
8. Event Handling: If needed, event handlers can be attached to the newly added elements or
existing ones to provide additional interactivity.
b) What are different looping statements in PHP? Explain.
 PHP provides several looping statements that allow us to execute a block of code repeatedly. The
main looping statements in PHP are:
1. for loop: The for loop is a common loop used when you know the number of iterations in
advance. It has three parts: initialization, condition, and increment/decrement. The loop continues
until the condition becomes false.
for ($i = 0; $i < 5; $i++) {
// code to be executed
}
2. while loop: The while loop executes a block of code as long as a specified condition is true. The
condition is checked before each iteration.
$i = 0;
while ($i < 5) {
// code to be executed
$i++;
}

3. do-while loop: The do-while loop is similar to the while loop, but it checks the condition after
each iteration. This guarantees that the block of code is executed at least once.
$i = 0;
do {
// code to be executed
$i++;
} while ($i < 5);

4. foreach loop: The foreach loop is used specifically for iterating over arrays or objects. It
automatically retrieves each element of an array or property of an object and assigns it to a
variable for further processing.
$fruits = array("apple", "banana", "orange");
foreach ($fruits as $fruit) {
// code to be executed for each element
echo $fruit;
}

Q5.
a) How can you load XML Data into an HTML Page? Explain with example.
 To load XML data into an HTML page, you can use JavaScript along with the XMLHttpRequest
object or the fetch API. Here's a general approach using the XMLHttpRequest object:
1. Create an XMLHttpRequest Object:
var xmlhttp = new XMLHttpRequest();
2. Define a callback function to handle the XML data once it’s loaded:
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
// XML data is loaded, handle it here
var xmlData = this.responseXML;
// Process and display the XML data as desired
}
};
3. Open the XML file using the XMLHttpRequest Object:
xmlhttp.open("GET", "path/to/your/xmlfile.xml", true);
4. Set the response type to “document” to indicate that the response is an XML document:
xmlhttp.responseType = "document";
5. Send the XMLHttpRequest to initiate the request:
xmlhttp.send();
6. Inside the callback function, you can access the loaded XML data through the responseXML
property of the XMLHttpRequest object. You can then manipulate the XML data and extract the desired
information to display on the HTML page.
b) Define ASP session object with properties and methods.
 In ASP (Active Server Pages), the Session object is a built-in object that allows you to store and
retrieve user-specific information across multiple pages during a user's session. It provides
properties and methods to manage session data. Here are some commonly used properties and
methods of the Session object:
Properties:

1. Session.Contents: Returns a collection of all items stored in the current session.


2. Session.SessionID: Returns a unique identifier for the current session.
3. Session.Timeout: Gets or sets the number of minutes of inactivity before a session is abandoned.
4. Session.Mode: Gets or sets the session state mode, such as "InProc" (in-process), "StateServer", or
"SQLServer".
Methods:
1. Session.Add(key, value): Adds a new item to the session with the specified key and value.
2. Session.Remove(key): Removes an item from the session using the specified key.
3. Session.RemoveAll(): Removes all items from the session.
4. Session.Abandon(): Abandons the current session and releases all session-specific resources.

Q6.
a) How can we add parameters and return values in PHP functions?
 In PHP, we can define functions that accept parameters and return values. Here's how you can add
parameters and return values in PHP functions:
1. Adding parameters:
We can define parameters in the function declaration to receive values from the calling code.
Parameters act as variables that hold the values passed to the function. You can then use these
values within the function's code. Syntax:
function functionName($param1, $param2, ...) {
// Function code that uses the parameters
}
2. Returning values: A function can return the value using the return statement. The returned value
can be of any data type, including strings, numbers, arrays, objects, etc. When a function
encounters the return statement, it immediately exits, and the specified value is returned to the
calling code.
Syntax:

function functionName($param1, $param2, ...) {


// Function code

return $value; // Value to be returned


}

b) How to establish MySQL connection and retrieve data using PHP Script? Explain with
example. Consider database named “UniversityDB” and table “Student”.
 To establish a MySQL connection and retrieve data using a PHP script, you can utilize the MySQLi
extension, which provides an object-oriented approach for interacting with MySQL databases. Here's
an example that demonstrates how to establish a connection, retrieve data from the "Student" table in
the "UniversityDB" database, and display the results:
$host = "localhost";
$username = "your_username";
$password = "your_password";
$database = "UniversityDB";

$connection = new mysqli($host, $username, $password, $database);

if ($connection->connect_error) {
die("Connection failed: " . $connection->connect_error);
}

$query = "SELECT * FROM Student";

$result = $connection->query($query);

if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$studentId = $row["student_id"];
$firstName = $row["first_name"];
$lastName = $row["last_name"];

echo "Student ID: " . $studentId . "<br>";


echo "Name: " . $firstName . " " . $lastName . "<br><br>";
}
} else {
echo "No data found.";
}

$connection->close();

You might also like