0% found this document useful (0 votes)
18 views19 pages

It602 23

Uploaded by

Sayantan Laha
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)
18 views19 pages

It602 23

Uploaded by

Sayantan Laha
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/ 19

2022-2023

Group A: Multiple Choice Questions

1. Node.js application runs on __________.


a) Multi thread
b) Single thread
c) All of these
d) None of these

2. Which is the method to create a new session in servlet?


a) request.getSession()
b) response.getSession()
c) request.createSession()
d) response.createSession()

3. Who is making the Web standards?


a) Mozilla
b) Microsoft
c) The World Wide Web Consortium
d) NVIDIA

4. In a Javascript Application, what function can be used to send messages to users requesting a text input?
a) Display()
b) Alert()
c) GetOutput()
d) Prompt()

5. Which HTML attribute is used to define inline styles?


a) class
b) Style
c) styles
d) Font

6. Which of the following is true about Web services?


a) Web services are open standard (XML, SOAP, HTTP etc.) based Web applications
b) Web services interact with other web applications for the purpose of exchanging data
c) Web Services can convert your existing applications into Web applications.
d) All of the above

7. CGI is a __________.
a) Client-side programming
b) Server-side programming
c) Both side programming
d) None of these

8. What does XML stand for?


a) Extra Marked Language
b) Extensible Markup Language
c) Extensible Marked Literal
d) Extra Markup Language

9. Applet is used in ______________ web page.


a) Dynamic webpage
b) Active
c) Both dynamic and static
d) Static

10. Which of these is a client-server application?


a) Web browsing
b) E-mail
c) Internet Chat
d) All of the above

11. Choose the correct HTML tag for the smallest heading.
a) <h6>
b) <heading small>
c) <small heading>
d) <h1>

12. What does error 404 or Not Found error while accessing a URL mean?
a) The server could not find the requested URL
b) Requested HTML file is not available
c) The path to the interpreter of the script is not valid
d) The requested HTML file does not have sufficient permissions

Short Answer Type Questions (Group B):

Q2. What is JDBC? What are the roles of Statement object and ResultSet in the JDBC framework?
JDBC (Java Database Connectivity):
JDBC is an API in Java that allows Java applications to connect and interact with databases. It provides methods to
execute SQL queries, retrieve data, and manage database transactions.

Roles of Statement and ResultSet:

1. Statement Object:
• Used to execute SQL queries (e.g., SELECT, INSERT, UPDATE, DELETE).
• Common types:
• Statement: Executes simple SQL statements without parameters.
• PreparedStatement: Allows parameterized queries for efficiency and security.
• CallableStatement: Executes stored procedures.
• Example:
Statement stmt = connection.createStatement();
String sql = "SELECT * FROM students";
ResultSet rs = stmt.executeQuery(sql);

2. ResultSet Object:
• Represents the result of a SQL query.
• Provides methods to iterate through rows and fetch data column-wise using methods
like getString(), getInt(), etc.
• Example:
while (rs.next()) {
System.out.println("Name: " + rs.getString("name"));
}

Q3. Explain RMI Architecture with a suitable diagram.

RMI (Remote Method Invocation):


RMI allows a Java program to invoke methods of an object located on a remote server, enabling distributed computing.

RMI Architecture:
1. Stub and Skeleton:
• The Stub is a proxy on the client-side that communicates with the server.
• The Skeleton is present on the server-side and passes the request to the actual implementation.
2. Remote Reference Layer:
• Manages references to remote objects and handles their communication.
3. Transport Layer:
• Handles the connection and communication between client and server over the network.
Diagram:

Client Application <-> Stub <-> Remote Reference Layer <-> Transport Layer <-> Skeleton <-> Server Object

Q4. What is HTTP? How does it work? Give an appropriate example.

HTTP (Hypertext Transfer Protocol):


HTTP is the protocol used for communication between web browsers (clients) and web servers. It defines how requests
and responses are formatted and transmitted.

Working of HTTP:

1. Request:
• A client (browser) sends a request to the server using methods like GET, POST, etc.
• Example: GET /index.html HTTP/1.1
Host: www.example.com
2. Response:
• The server processes the request and sends a response, typically containing HTML, CSS, JavaScript, or
error codes.
• Example: HTTP/1.1 200 OK
Content-Type: text/html
• html code:
<html>
<body>Hello, World!</body>
</html>
Example Workflow:
1. A user enters www.example.com in the browser.
2. The browser sends an HTTP GET request to the server.
3. The server responds with the requested HTML page.
4. The browser renders the page for the user.
Q5. (i) What is the use of AJAX?

AJAX (Asynchronous JavaScript and XML):


AJAX allows web pages to communicate with servers in the background without requiring a full-page reload. This
enhances the user experience by providing dynamic content updates.

Key Features of AJAX:


• Makes asynchronous requests to the server.
• Reduces server load and improves performance.
• Enables dynamic content updates, like live search or form validation.

Q5. (ii) Write AJAX code that will read data from a file.

Q6. What do you mean by SQL Injection? How can it be overcome?

SQL Injection:
SQL Injection is a type of security vulnerability that allows attackers to execute arbitrary SQL commands on a database by
injecting malicious code into a query.

Example of SQL Injection: SELECT * FROM users WHERE username = 'admin' OR '1'='1';

The above query always returns true, potentially exposing sensitive data.

Ways to Overcome SQL Injection:


1. Parameterized Queries:
• Use prepared statements to separate SQL logic from input data.
• Example (Java):
PreparedStatement stmt = connection.prepareStatement("SELECT * FROM users WHERE
username = ?"); stmt.setString(1, userInput);
ResultSet rs = stmt.executeQuery();
2. Input Validation:
• Validate user input to ensure it meets expected formats.
3. Stored Procedures:
• Use stored procedures that do not allow direct query concatenation.
4. Use ORMs (Object-Relational Mapping):
• Tools like Hibernate handle SQL generation and prevent injection.
5. Least Privilege Principle:
• Restrict database permissions for the application to minimize damage.

Group C: Long Answer Type Questions

Q7. (i) What is Servlet? Briefly explain the life cycle of a Servlet.
Servlet Overview:
A Servlet is a server-side Java program that extends the capabilities of servers hosting applications accessed by web
clients. Servlets dynamically process client requests and generate responses. Unlike static files (e.g., HTML), Servlets can
interact with databases, perform calculations, and update web pages dynamically.

Key Features of Servlets:


1. Platform-independent, leveraging Java’s "write once, run anywhere" capability.
2. Efficient and robust, using Java’s multi-threading and exception handling.
3. Supports session management using cookies and HTTP sessions.
4. Replaces CGI scripts for better scalability and performance.

Servlet Life Cycle:


A Servlet’s life cycle is managed by a web container (like Apache Tomcat) and involves three primary phases:

1. Initialization (init()):

o The init() method is called once when the Servlet is first loaded into memory.

o Used for resource allocation and initialization logic (e.g., database connection setup).

o Example:
public void init(ServletConfig config) throws ServletException {
super.init(config);
System.out.println("Servlet Initialized");
}
2. Request Handling (service()):

o The service() method handles incoming client requests.

o Depending on the request type (GET, POST, PUT, DELETE, etc.), it invokes methods like doGet() or
doPost().

o Processes user input, interacts with resources (e.g., databases), and generates responses.
o Example:
public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException,
IOException {
PrintWriter out = res.getWriter();
out.println("<h1>Welcome to Servlets!</h1>");
}
3. Destruction (destroy()):

o The destroy() method is called when the Servlet is unloaded from memory, typically during server
shutdown or re-deployment.

o Used for cleanup tasks like releasing database connections or file handles.

o Example:
public void destroy() {
System.out.println("Servlet Destroyed");
}

Complete Servlet Lifecycle Example with Diagram:

Client Request -> Web Server -> Servlet Container -> init() -> service() -> destroy() -> Response Sent to Client

Diagram:

+------------------------------+
Client ---> | Servlet Container |
| |
| 1. Loads Servlet Class |
| 2. Calls init() |
| 3. Calls service() |
| 4. Calls destroy() |
+------------------------------+
Advantages of Servlets Over CGI:
1. Efficiency: Servlets are multi-threaded, whereas CGI creates a new process for every request.
2. Scalability: Servlets can handle multiple requests efficiently.
3. Portability: Written in Java, servlets can run on any platform.
4. Integrated Session Management: Built-in support for maintaining user sessions.

Q7. (ii) Discuss MVC.

Model-View-Controller (MVC):
MVC is a software design pattern widely used for developing user interfaces that separates application logic into three
interconnected components:
• Model: Handles data and business logic.
• View: Manages the presentation of data to users.
• Controller: Acts as an intermediary, processing user inputs and updating the Model and View accordingly.

Components of MVC:
1. Model:
o Manages application data and state.
o Directly communicates with the database or other data sources.
o Example: A User class that defines attributes like id, name, and methods like save() or delete().
2. View:
o Displays data retrieved from the Model.
o Users interact with this layer via graphical or text-based interfaces.
o Example: HTML or JSP files that display user details.
3. Controller:
o Handles user requests, interacts with the Model, and decides which View to render.
o Example: A servlet or Spring controller that processes form submissions.

Working of MVC with Example:


1. A user interacts with the View (e.g., submitting a form).
2. The Controller receives the input, processes it, and updates the Model.
3. The Model interacts with the database and sends data back to the Controller.
4. The Controller updates the View, which displays the latest data.

Diagram:

[User] -> [Controller] -> [Model] -> [Database]


^ |
|------------ |

Advantages of MVC:

1. Separation of Concerns: Keeps business logic, UI, and user input handling separate.
2. Scalability: Easy to add new features or update existing ones.
3. Reusability: Components can be reused across applications.
4. Testability: Each layer can be tested independently.

Q8. (i) Define Web Technology. Draw Web Architecture and Explain.

Definition of Web Technology:Web technology refers to the tools, techniques, protocols, and frameworks that enable
communication, interaction, and functionality between web servers and clients (users). It facilitates the development of
websites and web applications, allowing users to access and interact with them over the internet.

Web technology encompasses:


• Front-End Technologies: HTML, CSS, JavaScript, and frameworks like React or Angular.
• Back-End Technologies: Server-side languages like Python, Java, PHP, and Node.js.
• Protocols and Standards: HTTP, HTTPS, FTP, REST APIs, and SOAP.
• Databases: Relational (MySQL, PostgreSQL) and NoSQL (MongoDB).

Web Architecture

Web architecture describes the structure and interaction between various components of a web system to provide
efficient functionality and scalability. It defines how a web application is designed, structured, and deployed.

Layers of Web Architecture:

1. Client Layer (Front-End):


o Represents the user interface of the web application.
o Includes web browsers and mobile apps that send requests to the server and display responses.
o Technologies: HTML, CSS, JavaScript.
o Example: A user opens a website and fills out a form.
2. Web Server Layer:
o Receives and processes client requests and routes them to the application server.
o Acts as a middleman between the client and the application.
o Example: Apache, Nginx.
3. Application Server Layer (Back-End):
o Contains the application logic or business logic of the system.
o Processes requests, interacts with databases, and performs computations.
o Technologies: Python (Django/Flask), Java (Spring), PHP, Node.js.
4. Database Layer:
o Stores and retrieves data required for the application.
o Databases can be relational (SQL-based) or NoSQL.
o Example: A user searches for a product, and the application retrieves product details from the database.

Diagram of Web Architecture:

Workflow of Web Architecture:


1. Request:
o A user enters a URL in the browser.
o The browser (client) sends an HTTP request to the web server.
2. Routing:
o The web server forwards the request to the application server.
3. Processing:
o The application server processes the request, applies business logic, and interacts with the database to
fetch or update data.
4. Response:
o The application server sends the processed data to the web server, which forwards it to the client
browser.
5. Rendering:
o The browser renders the response (HTML, CSS, JavaScript) for the user.

Advantages of Web Architecture:


1. Scalability: Can handle increasing user traffic efficiently by adding more servers or balancing the load.
2. Modularity: Separates the client, server, and database, allowing independent development and maintenance.
3. Interoperability: Supports integration with third-party services like payment gateways and APIs.
4. Flexibility: Allows deployment of applications on multiple platforms (desktop, mobile, etc.).

Q8. (ii) What Are HTML Tags? How Can You Insert Rows and Columns in HTML?
HTML Tags: HTML (Hypertext Markup Language) tags are predefined elements enclosed within angle brackets (< >).
These tags structure and define content on a web page. Most HTML tags come in pairs, such as <p> (opening tag) and
</p> (closing tag).

Types of HTML Tags:


1. Structural Tags: <html>, <head>, <body>.
2. Formatting Tags: <b>, <i>, <u>.
3. Media Tags: <img>, <video>.
4. Table Tags: <table>, <tr>, <td>, <th>.

Example(HTML code):

<!DOCTYPE html>
<html>
<head>
<title>HTML Tags Example</title>
</head>
<body>
<h1>Welcome to HTML</h1>
<p>This is a paragraph.</p>
</body>
</html>

Inserting Rows and Columns in HTML: HTML tables use tags like <table>, <tr> (table row), <td> (table data), and <th>
(table header) to create and organize rows and columns.

Explanation of Table Tags:


1. <table>: Defines the table.
2. <tr> (Table Row): Represents a row in the table.
3. <th> (Table Header): Represents a header cell, typically bold and centered.
4. <td> (Table Data): Represents a data cell.

Advantages of Using Tables:


1. Useful for organizing and displaying tabular data like reports and charts.
2. Easy integration with CSS for styling and JavaScript for dynamic behaviors.
Limitations:
1. Not suitable for layout design in modern responsive web design.
2. Overuse can lead to poor accessibility and code readability.

Q9. (i) Compare doGet() and doPost(). Write a Servlet that will remember the username and password using cookies.

Key Differences:

• GET is mainly used for retrieving data, while POST is used for submitting data to the server (e.g., form
submission).

• GET requests append data to the URL, making them visible to anyone who has access to the URL (less secure).
POST requests hide the data within the body, making them suitable for sensitive information.

• GET is generally faster as it is cached by browsers, whereas POST is not cached and is thus used for operations
that require a side effect on the server (such as submitting a form to save data).

Servlet Example: Remember Username and Password Using Cookies

In this example, we’ll create a simple servlet that accepts a username and password via a form, and then stores this
information in a cookie so that it can "remember" the user on subsequent visits.

Java Servlet Code:


import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class RememberMeServlet extends HttpServlet {


@Override
protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
// Get the username and password from the request parameters
String username = req.getParameter("username");
String password = req.getParameter("password");

// Create cookies to store the username and password


Cookie userCookie = new Cookie("username", username);
Cookie passCookie = new Cookie("password", password);

// Set the maximum age of the cookies (1 day)


userCookie.setMaxAge(60 * 60 * 24); // 1 day
passCookie.setMaxAge(60 * 60 * 24); // 1 day

// Add the cookies to the response


res.addCookie(userCookie);
res.addCookie(passCookie);

// Set the content type for the response


res.setContentType("text/html");

// Get the output stream


PrintWriter out = res.getWriter();

// Generate the HTML response


out.println("<html>");
out.println("<head><title>Remember Me</title></head>");
out.println("<body>");
out.println("<h1>Welcome, " + username + "!</h1>");
out.println("<p>Your username and password are now remembered for 1 day.</p>");
out.println("</body>");
out.println("</html>");
}

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
// Retrieve cookies from the request
Cookie[] cookies = req.getCookies();
String username = "";
String password = "";

if (cookies != null) {
for (Cookie cookie : cookies) {
if ("username".equals(cookie.getName())) {
username = cookie.getValue();
}
if ("password".equals(cookie.getName())) {
password = cookie.getValue();
}
}
}

// Set the content type for the response


res.setContentType("text/html");
PrintWriter out = res.getWriter();

// Generate HTML response to show remembered details


out.println("<html>");
out.println("<head><title>Welcome Back</title></head>");
out.println("<body>");
if (!username.isEmpty()) {
out.println("<h1>Welcome back, " + username + "!</h1>");
out.println("<p>Your password is: " + password + "</p>");
} else {
out.println("<h1>Welcome, Guest!</h1>");
out.println("<p>You have not logged in yet.</p>");
}
out.println("</body>");
out.println("</html>");
}
}

Explanation of the Code:

1. doPost() Method:
o This method is called when the user submits the form with their username and password.
o The servlet extracts the values from the request parameters and creates cookies to store the username
and password.
o The cookies are given a maximum age of 24 hours (60 * 60 * 24 seconds) so that the browser will store
them for that period.
o The cookies are added to the response using res.addCookie(), allowing the browser to store them.
o The response includes a simple HTML page confirming that the username and password have been
stored.
2. doGet() Method:
o This method is used to retrieve the cookies from the client’s browser when they return to the website.
o The servlet looks for the "username" and "password" cookies and displays their values on the page.
o If the cookies are present, the servlet greets the user by their username and shows the stored password.
If the cookies are absent, it displays a generic message.

HTML Form for Username and Password Submission:

<!DOCTYPE html>
<html>
<head>
<title>Login Form</title>
</head>
<body>
<h2>Login Form</h2>
<form action="RememberMeServlet" method="POST">
<label for="username">Username:</label>
<input type="text" id="username" name="username"><br><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password"><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>

Q10. (i) What is CGI? Write a CGI Program.

CGI (Common Gateway Interface):


CGI is a standard for interfacing external applications with web servers to create dynamic web pages. CGI allows the web
server to interact with programs or scripts written in various languages such as Perl, Python, C, etc., and then pass the
output of these programs back to the client (user's browser). It provides a way for the server to process requests and
generate dynamic content on the fly, which is particularly useful for web applications that need to interact with
databases, accept user input, or perform complex calculations.

Working of CGI:
1. Request from Client: The client sends an HTTP request to the web server.
2. CGI Program Execution: The server invokes a CGI script/program (e.g., written in Python, Perl, etc.) based on the
requested URL.
3. Processing and Output: The CGI script processes the input and outputs an HTML response.
4. Response to Client: The output is sent back to the client as a response, which could include dynamic content
such as data fetched from a database or calculated results.
How CGI Works:
• The server passes the HTTP request (such as form data) to the CGI program via environment variables and
standard input.
• The CGI program performs operations (e.g., query a database, process data, generate content) and then
generates an HTTP response, which is sent back to the browser.
Advantages of CGI:
1. Language Independence: CGI programs can be written in any programming language that supports standard
input/output.
2. Separation of Concerns: The web server handles incoming requests, and the CGI script handles the processing of
business logic.
3. Dynamic Content Generation: CGI allows for the creation of dynamic content based on user input, data, or other
parameters.
4. Scalability: CGI can handle a large number of users, though not as efficiently as newer technologies (e.g.,
servlets).
Disadvantages of CGI:
1. Performance: Each request results in a new process being spawned, which can be resource-intensive and slow,
especially with high traffic.
2. State Management: Managing sessions in CGI is not as straightforward as in newer technologies like JSP or
servlets.
3. Security: Improper implementation of CGI scripts can lead to security vulnerabilities such as buffer overflows or
command injections.
CGI Program Example: Here’s an example of a Python CGI program that outputs a simple HTML page. This program
reads query parameters from a form submission and displays them:

Python CGI Program:

#!/usr/bin/env python3
import cgi
# Send the content type header
print("Content-type: text/html\n")

# Create a FieldStorage instance to hold form data


form = cgi.FieldStorage()

# Fetch form values


name = form.getvalue("name")
age = form.getvalue("age")

# HTML Output
print("<html>")
print("<head><title>CGI Example</title></head>")
print("<body>")
print("<h1>Welcome to CGI!</h1>")
print(f"<p>Name: {name}</p>")
print(f"<p>Age: {age}</p>")
print("</body>")
print("</html>")
Explanation:
• #!/usr/bin/env python3: This line is called a shebang and tells the server that this is a Python program to be
executed.
• import cgi: This imports the CGI module that provides tools for handling form data.
• print("Content-type: text/html\n"): Sends the HTTP header to inform the client that the content returned will
be in HTML format.
• cgi.FieldStorage(): This creates an instance that retrieves form data sent via the HTTP request.
• form.getvalue(): This method retrieves the value associated with the specified form field.
• The program then generates a simple HTML page displaying the user's name and age.

CGI Program Example with HTML Form:

To test the CGI program, you would need an HTML form that submits data to this CGI script. Here's a sample HTML form
that collects the user's name and age:

<!DOCTYPE html>
<html>
<head>
<title>CGI Form Example</title>
</head>
<body>
<h1>Enter your details:</h1>
<form method="get" action="/cgi-bin/display.py">
Name: <input type="text" name="name"><br>
Age: <input type="text" name="age"><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
Explanation of HTML Form:
• <form method="get" action="/cgi-bin/display.py">: This form sends the input data to the CGI program
display.py located in the cgi-bin directory.
• name="name": This is the name of the form field for the user's name.
• name="age": This is the name of the form field for the user's age.
• <input type="submit">: This button submits the form to the server.
When the user fills in the form and submits it, the CGI script processes the data and returns the result in a dynamic
HTML page showing the entered name and age.

Q10. (ii) Explain Java Applet Life Cycle.

Java Applet Life Cycle:


An applet is a small Java program that can be embedded in a webpage and executed on the client-side by a web browser.
The life cycle of an applet consists of four main methods: init(), start(), stop(), and destroy(). These methods allow the
applet to be initialized, run, stopped, and destroyed during its execution in a browser.

Applet Life Cycle Methods:

1. init():
o This method is called once when the applet is first loaded into the browser or applet viewer.
o It is used to initialize the applet and set up resources such as graphics or data structures.
o Example:
public void init() {
System.out.println("Applet initialized");
}
2. start():
o This method is called immediately after init() and whenever the applet is resumed (e.g., when the user
returns to the page).
o It is used to start any ongoing tasks such as animations or threads.
o Example:
public void start() {
System.out.println("Applet started");
}
3. stop():
o This method is called when the user navigates away from the page, or when the applet is no longer
needed (e.g., when the browser window is minimized).
o It is used to stop any ongoing tasks and to release resources such as threads or network connections.
o Example:
public void stop() {
System.out.println("Applet stopped");
}
4. destroy():

o This method is called when the applet is being unloaded or the browser is closed.
o It is used for cleanup, such as releasing memory or closing open resources.
o Example:
public void destroy() {
System.out.println("Applet destroyed");
}
Diagram of Applet Life Cycle:
init() -> start() -> (repeat start() and stop() if the applet is active) -> stop() -> destroy()

Complete Example(java):

import java.applet.Applet;
import java.awt.Graphics;
public class AppletLifeCycle extends Applet {
public void init() {
System.out.println("Applet initialized.");
}
public void start() {
System.out.println("Applet started.");
}
public void stop() {
System.out.println("Applet stopped.");
}
public void destroy() {
System.out.println("Applet destroyed.");
}
public void paint(Graphics g) {
g.drawString("Applet Life Cycle", 20, 20);
}
}
Explanation:
• paint(): The paint() method is called whenever the applet needs to refresh the user interface or output.
• The other methods (init(), start(), stop(), destroy()) are invoked by the browser based on the applet's state.

Key Takeaways:
• Initialization and Setup: Handled by init() and start().
• Resource Management: Handled by stop() and destroy().
• Interaction: paint() handles drawing on the applet's canvas.

Q10. (iii) Explain DNS and HTTP.

DNS (Domain Name System):


DNS is a hierarchical system that converts human-readable domain names (like www.google.com) into IP addresses (like
142.250.190.14), which computers use to communicate over the internet. Without DNS, users would have to remember
the IP addresses of every website they visit.

• How DNS Works:


1. A user types a URL in the browser (e.g., www.google.com).
2. The browser queries the DNS server to resolve the domain name into an IP address.
3. The DNS server returns the IP address, and the browser sends a request to the web server using this IP.

HTTP (HyperText Transfer Protocol):


HTTP is the protocol used for communication between clients (e.g., web browsers) and servers. It defines how requests
and responses are structured.

• HTTP Methods:
o GET: Fetches data from the server.
o POST: Sends data to the server (e.g., form submission).
o PUT: Updates data on the server.
o DELETE: Removes data from the server.

Example of HTTP Request and Response:

• Request:
A browser sends an HTTP GET request for a webpage:
GET /index.html HTTP/1.1
Host: www.example.com

• Response:
The server responds with an HTTP status code and the requested content:

HTTP/1.1 200 OK
Content-Type: text/html
<html><body><h1>Hello, World!</h1></body></html>

Q11. Write short notes on any three of the following:.

(i) MongoDB

Definition:
MongoDB is a NoSQL database that stores data in a flexible, document-oriented format, using JSON-like structures called
BSON (Binary JSON). It is designed for scalability and high performance, particularly for handling large datasets.

Key Features:
1. Schema-less: No predefined schema is required, allowing flexibility in data structure.
2. Horizontal Scalability: Data can be distributed across multiple servers (sharding).
3. Rich Query Language: Supports filtering, aggregation, and map-reduce operations.
4. High Availability: Built-in replication ensures fault tolerance.
5. Indexing: Supports single-field, compound, geospatial, and text indexing.

Example:

{
"name": "John Doe",
"email": "[email protected]",
"age": 29,
"skills": ["Java", "Python", "Node.js"]
}
Advantages of MongoDB:
• Handles unstructured or semi-structured data.
• Ideal for modern applications like real-time analytics, IoT, and content management systems.
Use Cases:
• E-commerce platforms.
• Social networking applications.

(ii) XML

Definition:
XML (Extensible Markup Language) is a markup language designed for storing and transporting data. It is both human-
readable and machine-readable.
Features:
1. Self-descriptive: Tags define the structure of the data.
2. Platform-independent: Works across different platforms and systems.
3. Customizable Tags: Allows users to define their own tags.
4. Hierarchical Structure: Data is stored in a tree-like format.
Example:
<employee>
<name>John Doe</name>
<department>IT</department>
<age>29</age>
</employee>
Advantages of XML:
• Ensures data interoperability between systems.
• Provides a standard format for data storage and transmission.
Applications of XML:
• Configuration files.
• Web services (SOAP).
• RSS feeds.

(iii) Node.js

Definition:
Node.js is an open-source, cross-platform runtime environment for executing JavaScript code outside a web browser. It
uses the V8 JavaScript engine and is designed for building scalable, server-side applications.

Key Features:
1. Event-Driven: Handles multiple requests asynchronously using an event loop.
2. Non-Blocking I/O: Performs I/O operations without blocking the execution thread.
3. Single Threaded: Uses a single thread with event delegation for concurrency.
4. NPM (Node Package Manager): Offers a vast library of pre-built packages.
Example(javascript): Simple HTTP server in Node.js:
const http = require('http');
http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello, World!');
}).listen(3000);
console.log('Server running on http://localhost:3000/');

Advantages of Node.js:
• Lightweight and efficient for real-time applications.
• Ideal for data-intensive applications like chat systems or gaming servers.

(iv) SAX and DOM


SAX (Simple API for XML):
• An event-driven, streaming approach to parsing XML documents.
• Reads XML sequentially, making it memory efficient.
• Ideal for large XML files.
DOM (Document Object Model):
• Loads the entire XML document into memory and represents it as a tree structure.
• Allows manipulation of elements and attributes.
• Suitable for smaller XML documents requiring frequent updates.

Comparison:

Feature SAX DOM


Memory Usage Low (processes in chunks). High (entire document in memory).
Speed Faster for large documents. Slower due to loading entire file.
Access Sequential access only. Random access possible.
Example of DOM (Java):

import org.w3c.dom.*;
import javax.xml.parsers.*;
public class DOMExample {
public static void main(String[] args) throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse("example.xml");

NodeList nodes = doc.getElementsByTagName("employee");


for (int i = 0; i < nodes.getLength(); i++) {
Element element = (Element) nodes.item(i);
System.out.println("Name: " + element.getElementsByTagName("name").item(0).getTextContent());
}
}
}

(v) VoIP (Voice over Internet Protocol)

Definition:
VoIP enables voice communication and multimedia sessions over the internet instead of traditional telephone networks.

How VoIP Works:


1. Converts analog voice signals into digital data packets.
2. Transmits these packets over the internet.
3. At the receiving end, the packets are converted back to audio signals.
Features:
1. Cost-Effective: Reduces costs compared to traditional telephony.
2. Mobility: Users can make calls from any internet-enabled device.
3. Integration: Combines with other services like video conferencing and instant messaging.
Applications:
• Skype, Zoom, and Microsoft Teams.
• Call centers and customer support services.
Advantages of VoIP:
1. Eliminates the need for separate voice and data networks.
2. Scalable for businesses of all sizes.
3. Offers advanced features like call forwarding, voicemail, and analytics.

You might also like