???????? ??????????? ??? ???
???????? ??????????? ??? ???
<video> Element - The <video> element is used to embed video content on a webpage. Like <audio>, it supports various
video file formats, and you can provide multiple source elements for compatibility.
Example:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h2>Click play button to play video</h2>
<video src="./test.mp4" controls></video>
</body>
</html>
Q2 Difference Between HTML And HTML5.
Ans.
HTML HTML5
1 It Didn’t Support Audio And Video Without The Use 1 It Supports Audio And Video Controls With The Use
Of Flash Player Support. Of <Audio> & <Video> Tags.
2 It Uses Cookies To Store Temporary Data. 2 It Uses SQL Databases And Application Cache To
Store Offline Data.
3 Does Not Allow JavaScript To Run In Browser. 3 Allows JavaScript To Run In Background. This Is
Possible Due To JS Web Worker API In HTML5.
4 It Does Not Allow Drag And Drop Effects. 4 It Allows Drag And Drop Effects.
5 It Works With All Old Browsers. 5 It Supported By All New Browser Like Firefox,
Mozilla, Chrome, Safari, Etc.
6 Older Version Of HTML Are Less Mobile Friendly. 6 HTML5 Language Is More Mobile Friendly.
7 Doctype Declaration Is Too Long And Complicated. 7 Doctype Declaration Is Quite Simple And Easy.
8 Elements Like Nav, Header Were Not Pleasant. 8 New Elements For Web Structure Like Nav, Header,
Footer Etc.
9 Character Encoding Is Long And Complicated. 9 Character Encoding Is Simple And Easy.
10 It Can Not Handle Inaccurate Syntax. 10 It Is Capable Of Handling Inaccurate Syntax.
JavaScript
// Get the element by its ID
var myBox = document.getElementById("myBox");
Q6 Explain Basic Internet Protocols Which Are Essential For Transferring Data And Sending Emails.
Ans.
Data Transfer Protocols:
1. HTTP (Hypertext Transfer Protocol):
• Purpose: Used for transferring hypertext (web pages and files) on the World Wide Web.
• Details: Standard protocol for web browsing. It operates on top of the TCP/IP protocol.
2. HTTPS (Hypertext Transfer Protocol Secure):
• Purpose: Secure version of HTTP, providing encrypted communication.
• Details: It uses SSL/TLS protocols to ensure the security and privacy of data transferred between the user and the
website.
3. FTP (File Transfer Protocol):
• Purpose: Used for transferring files between a client and a server on a computer network.
• Details: Supports two modes, ASCII and Binary, and requires authentication to access files.
4. SFTP (SSH File Transfer Protocol):
• Purpose: Secure alternative to FTP, providing file transfer and manipulation capabilities.
• Details: Encrypted using the SSH (Secure Shell) protocol, ensuring secure data transmission.
5. SMTP (Simple Mail Transfer Protocol):
• Purpose: Used for sending emails from a client to a server or between servers.
• Details: Works in collaboration with other protocols like POP3 and IMAP to handle email communication.
Email Protocols:
1. POP3 (Post Office Protocol version 3):
• Purpose: Retrieves emails from a mail server to a local client.
• Details: Typically used for downloading emails to a single device. Emails are usually deleted from the server after
retrieval.
2. IMAP (Internet Message Access Protocol):
• Purpose: Allows users to access and manage their email messages on a mail server.
• Details: Supports multiple devices, and emails remain on the server. Changes made on one device are reflected on
others.
3. SMTP (Simple Mail Transfer Protocol):
• Purpose: Sends emails from a client to a server or between servers.
• Details: Works in collaboration with POP3 and IMAP. Responsible for the outgoing email flow.
4. MIME (Multipurpose Internet Mail Extensions):
• Purpose: Extends the format of email messages to support text in character sets other than ASCII, as well as
attachments of audio, video, images, and application programs.
• Details: Allows emails to include multimedia elements and attachments.
5. DNS (Domain Name System):
• Purpose: Resolves domain names to IP addresses, facilitating email routing.
• Details: Essential for translating human-readable domain names into machine-readable IP addresses.
Servlet Lifecycle:
1. Instantiation:
• The servlet container creates an instance of the servlet by calling its no-argument constructor.
2. Initialization (init method):
• The container calls the init method after instantiating the servlet.
• Initialization tasks, such as setting up resources, can be performed here.
3. Request Handling (service method):
• The service method is called to handle each client request.
• This method dispatches the request to the appropriate doXxx method (e.g., doGet, doPost) based on the HTTP
method.
4. Request Completion:
• After the service method completes, the response is sent back to the client.
5. Destruction (destroy method):
• The destroy method is called by the container before removing the servlet instance.
• Clean-up tasks, such as releasing resources, can be performed here.
6. Servlet Removal:
• The servlet container removes the servlet instance when it is no longer needed or when the server is shut down.
Q2 List And Explain Session Tracking Techniques.
Ans.
Session tracking is a mechanism used in web development to maintain state information about a user across multiple
requests. It allows the server to recognize the same user across different pages and requests. Various session tracking
techniques are employed to achieve this.
Session Tracking Techniques:
1. Cookies:
• Explanation: Cookies are small pieces of data sent by the server and stored on the client's machine. They are sent
with every HTTP request, allowing the server to identify the client.
• Implementation: The server includes a Set-Cookie header in the HTTP response to set a cookie on the client, and
the client sends the cookie back with subsequent requests.
2. URL Rewriting:
• Explanation: Session information is encoded in the URL itself. Each URL includes a unique session identifier,
which the server uses to identify the client.
• Implementation: The server appends the session ID to URLs, and the client sends this session ID with each
subsequent request.
3. Hidden Form Fields:
• Explanation: Session information is stored as hidden fields within HTML forms. When the user submits the
form, the session data is sent to the server.
• Implementation: The server includes hidden input fields in HTML forms containing the session information.
4. HTTP Session:
• Explanation: A server-side session management mechanism provided by web frameworks. It uses cookies or
URL rewriting to associate a session ID with a user.
• Implementation: Web frameworks, such as Java EE (using HttpSession), provide built-in support for managing
user sessions.
Q2 Explain AJAX Web Application Model And Traditional Web Application Model With Diagram.
Ans.
AJAX Web Application Model:
AJAX (Asynchronous JavaScript and XML) introduces an asynchronous communication pattern between the client and
server, enabling partial updates of web pages without requiring a full page reload. This results in a more dynamic and
responsive user experience.
Components in AJAX Web Application Model:
1. User Interface (UI) -
• The client-side interface presented to the user, typically consisting of HTML, CSS, and JavaScript.
2. User Action -
• Any action initiated by the user, such as clicking a button or submitting a form.
3. Asynchronous JavaScript (AJAX) Request -
• The user action triggers an asynchronous AJAX request to the server.
4. Server-Side Processing -
• The server processes the request, performs any necessary computations or database operations, and returns data
(usually in JSON or XML format) instead of an entire HTML page.
5. Partial Update of UI -
• The client-side JavaScript receives the server's response and dynamically updates only the relevant portions of the
web page, without requiring a full reload.
Q3 What Is AJAX.
Ans.
AJAX (Asynchronous JavaScript and XML) is a set of web development techniques that allows web pages to be updated
asynchronously by exchanging small amounts of data with the server behind the scenes. This enables web applications to
dynamically update content, retrieve data, and interact with the server without requiring a full page reload. AJAX is not a
programming language or a technology on its own; rather, it is a combination of several existing technologies.
Key Components And Concept Of AJAX:
1. Asynchronous Requests:
• AJAX enables asynchronous communication between the web browser and the server. This means that the web
page can send requests to the server and continue to process user actions without waiting for the server's response.
2. XMLHttpRequest Object:
• The XMLHttpRequest object is a core component of AJAX. It is a JavaScript object that provides an easy way to
make asynchronous HTTP requests to the server. The object can send data to the server and receive the server's
response.
3. Data Formats (XML, JSON):
• While the "X" in AJAX originally stood for XML, modern AJAX applications often use JSON (JavaScript Object
Notation) as a data interchange format. JSON is more lightweight and easier to parse in JavaScript, but XML is
still used in some cases.
4. Event Handling:
• AJAX leverages event-driven programming. Developers can define event handlers that are triggered when an
asynchronous operation completes, such as when data is successfully received from the server.
5. DOM Manipulation:
• Once data is received from the server, AJAX allows dynamic manipulation of the Document Object Model
(DOM) to update specific parts of a web page without requiring a full reload. This leads to a more seamless and
interactive user experience.
6. Cross-Browser Compatibility:
• AJAX is designed to work across different web browsers, ensuring that web applications behave consistently
regardless of the browser being used. This is achieved by handling browser-specific implementation details in the
AJAX code.
7. Benefits:
• Improved User Experience: AJAX allows for a more responsive and interactive user experience by updating
content dynamically without reloading the entire page.
•Reduced Server Load: Since only the necessary data is exchanged, AJAX can lead to reduced server load and
improved performance.
• Asynchronous Operations: User actions can trigger asynchronous operations, allowing the application to continue
processing without waiting for the server response.
8. Common Use Cases:
• Dynamic content loading (e.g., updating parts of a page without refreshing).
• Form submission without page reload.
• Auto-complete suggestions in search fields.
• Real-time data updates in chat applications.
• The className attribute is used to apply a dynamic CSS class to the <h1> element.
• The <a> (anchor) element has dynamic values for the href, target, and rel attributes.
• The disabled attribute of the <button> element is set based on the value of the isButtonDisabled variable.
Sample Codes From PYQ.
Note – Following All Codes Are Created By Ai And Downloaded From Different Websites, The Concept Or Pattern
Of Writing Codes Are Different of Every Person, You Can Use This Codes If You Are Comfortable With It. Check
Before Apply.
Q1 Write A Code To Drag An Image From Outside The Box And Drop It Inside The Box.
Ans.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
#drop-box {
width: 300px;
height: 200px;
border: 2px dashed #ccc;
position: relative;
}
#drag-image {
width: 100px;
height: 100px;
position: absolute;
}
</style>
<title>Drag and Drop Image</title>
</head>
<body>
function drag(event) {
// Set the dragged data (in this case, the image source URL)
event.dataTransfer.setData("text", event.target.src);
}
function drop(event) {
event.preventDefault();
var data = event.dataTransfer.getData("text");
// Create a new image element and set its source to the dropped data
var droppedImage = new Image();
droppedImage.src = data;
droppedImage.width = 100; // You can adjust the size as needed
</body>
</html>
Q2 Write A JavaScript Code To Check Password And Confirm Password Are Same Or Not.
Ans.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Password Matching Example</title>
</head>
<body>
<br>
<br>
<script>
function validateForm() {
var password = document.getElementById("password").value;
var confirmPassword = document.getElementById("confirmPassword").value;
</body>
</html>
function HelloWorld() {
return (
<div>
<h1>Hello World</h1>
</div>
);
}
</body>
</html>
Q5 Write A JSP Program To Perform Four Basic Arithmetic Operations Addition, Subtraction, Division &
Multiplication.
Ans.
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
function multiply(){
a=Number(document.my_cal.first.value);
b=Number(document.my_cal.second.value);
c=a*b;
document.my_cal.total.value=c;
}
function addition(){
a=Number(document.my_cal.first.value);
b=Number(document.my_cal.second.value);
c=a+b;
document.my_cal.total.value=c;
}
function subtraction(){
a=Number(document.my_cal.first.value);
b=Number(document.my_cal.second.value);
c=a-b;
document.my_cal.total.value=c;
}
function division(){
a=Number(document.my_cal.first.value);
b=Number(document.my_cal.second.value);
c=a/b;
document.my_cal.total.value=c;
}
function modulus(){
a=Number(document.my_cal.first.value);
b=Number(document.my_cal.second.value);
c=a%b;
document.my_cal.total.value=c;
}
</script>
<br>
<!-- Here user will enter 2nd number. -->
Number 2: <input type="text" name="second">
<br><br>
<br><br>
</body>
</html>
Q7 Write The AJAX Code To Read From The Text File And Displaying It After Clicking Of A Button.
Ans.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Read Text File with AJAX</title>
</head>
<body>
<script>
document.getElementById('loadButton').addEventListener('click', function() {
// Using fetch to read the text file
fetch('yourfile.txt')
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.text();
})
.then(data => {
// Display the content in the 'content' div
document.getElementById('content').innerHTML = data;
})
.catch(error => {
console.error('There was a problem with the fetch operation:', error);
});
});
</script>
</body>
</html>
Q8 Write HTML Code For Embedding Audio And Video Elements In The Web Page.
Ans.
For Embedding Audio:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Audio Example</title>
</head>
<body>
<h2>Embedded Audio</h2>
<audio controls>
<source src="your-audio-file.mp3" type="audio/mp3">
Your browser does not support the audio element.
</audio>
</body>
</html>
For Embedding Video:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Video Example</title>
</head>
<body>
<h2>Embedded Video</h2>
</body>
</html>