Web Technology Important Questions
Web Technology Important Questions
1. What is CSS? Discuss types of CSS with example. CSS (Cascading Style Sheets) is
used for designing layouts with HTML. There are different approaches to style
sheets, including external, internal, and inline.
o Types of CSS:
External CSS: Styles are defined in an external .css file and linked to
the HTML document. This is good for applying the same style to
multiple pages.
Internal CSS: Styles are defined within <style> tags in the <head>
section of an HTML document. This is useful for styling a single page.
Inline CSS: Styles are applied directly to an HTML element using the
style attribute. This is suitable for unique styles for a single element.
2. What is CSS Box Model? Describe its components with example. The CSS Box
Model is a conceptual box that wraps around every HTML element. It consists of
four main components, from the innermost to the outermost:
o Content: The actual content of the element, such as text or images.
o Padding: The space between the content and the border.
o Border: A line that goes around the padding and content.
o Margin: The space outside the border, between the element and other
elements.
o Example (Conceptual): Imagine a paragraph of text. The text itself is the
content. You can add padding around the text, then a border around that
padding, and finally margin to create space between the paragraph and an
adjacent image.
3. Write HTML and CSS code to design your curriculum vitae (CV) using different
HTML elements like table, image, formatting tags, links.
(For your exam, you should be prepared to write a basic structure demonstrating
these elements. Here's a conceptual outline of what you'd include, as direct code
cannot be provided in this format, but the task involves creating HTML forms,
tables, and web pages, designing layouts using CSS, and using HTML lists,
formatting tags, and image maps.)
o HTML Structure:
Use <h1> for your name, <h2> for sections (e.g., "Education,"
"Experience").
Use <p> for paragraphs of text.
Use
Use
Use
Use
o CSS Styling:
Apply styles to center elements, set font families/sizes, and define
colors.
Style tables with borders and padding for readability.
Use CSS for layout (e.g., using
(For your exam, be ready to write the HTML code for a form. The task involves
creating HTML forms.)
o HTML Structure:
Use the <form> tag.
Use <label> for input fields.
Use <input type="text"> for name and address.
Use <input type="email"> for email.
Use <input type="radio"> for gender selection.
Use <textarea> for larger text inputs (e.g., address).
Include a <button type="submit"> to submit the form.
5. What are block-level and inline-level elements? Differentiate with examples.
o Block-level elements:
Start on a new line and take up the full width available.
Can contain other block-level elements and inline-level elements.
Examples:
o Inline-level elements:
Do not start on a new line and only take up as much width as
necessary.
Cannot contain block-level elements.
Examples:
o Differentiation: The primary difference lies in how they occupy space and
how they can contain other elements. Block-level elements are like
paragraphs or headings, creating distinct blocks, while inline-level elements
are like words within a sentence, flowing with the text.
6. Explain how to create and use image maps (Client-Side and Server-Side). Image
maps allow different parts of an image to be clickable, linking to different
destinations.
o Client-Side Image Maps:
Processed entirely by the user's browser.
Created using the
The usemap attribute of the <img> tag points to the name attribute of
the <map> tag.
<area> tags define clickable regions (rect, circle, poly) with coords
and href attributes.
Advantage: Faster response time as no server request is needed.
o Server-Side Image Maps:
Processing occurs on the web server.
The
<img> tag has an ismap attribute and is placed inside an <a> tag that
points to a server-side script.
When a user clicks on the image, the browser sends the click
coordinates to the server-side script, which then determines the
appropriate action.
Disadvantage: Slower response time due to server communication.
7. Describe the structure and attributes of HTML tables, including rowspan and
colspan. HTML tables are used to display tabular data.
o Structure:
<table>: The root element for a table.
<thead>: Groups header content in a table (optional).
<tbody>: Groups the body content in a table (optional).
<tfoot>: Groups footer content in a table (optional).
<tr>: Defines a table row.
<th>: Defines a header cell in a table.
CREATED BY: AARYAN JHA
1. Explain tier architecture. Differentiate between 2-tier and 3-tier architecture with
examples. Tier architecture refers to the distribution of software components across
different logical layers or physical machines to handle specific functions.
o 2-Tier Architecture:
Structure: Typically consists of a client tier (presentation layer) and a
server tier (data layer).
Client Tier: Handles the user interface and business logic.
Server Tier: Handles data storage and retrieval (e.g., a database
server).
Interaction: The client directly communicates with the database
server.
Example: A simple desktop application directly connecting to a
database. In web context, a simple static website directly accessing a
database without an intermediate application server.
Pros: Simpler to develop for small applications.
Cons: Limited scalability, poor security (client has direct database
access), difficult to manage logic changes.
o 3-Tier Architecture:
Structure: Consists of three distinct layers: Presentation Tier,
Application (or Logic) Tier, and Data Tier.
Presentation Tier (Client): User interface (e.g., web browser).
Application Tier (Middle Tier): Contains the business logic, processes
requests from the client, and interacts with the data tier. This
separates the client from direct database access.
Data Tier: Stores and manages data (e.g., database server).
Interaction: Client interacts with the application tier, which then
interacts with the data tier.
Example: A typical e-commerce website where the web browser
(presentation) interacts with an application server (e.g., running Java,
Python, or PHP code for business logic), which then communicates
with a database (data).
Pros: Improved scalability, enhanced security (no direct database
access from client), easier maintenance and development due to
separation of concerns, greater flexibility.
Cons: More complex to design and implement.
2. Explain multi-tier web architecture with its advantages and disadvantages. Multi-
tier web architecture is an extension of the 3-tier model, involving more than three
layers to distribute various components and functionalities across different servers
or processes. It's a common approach for complex, large-scale web applications.
o Common Tiers (beyond 3-tier):
Web Server Tier: Handles HTTP requests and serves static content
(e.g., Apache, Nginx).
Application Server Tier: Executes dynamic content and business logic
(e.g., Tomcat, JBoss, Node.js).
Database Tier: Stores and manages data (e.g., MySQL, PostgreSQL).
CREATED BY: AARYAN JHA
Caching Tier: Stores frequently accessed data for faster retrieval (e.g.,
Redis, Memcached).
Load Balancer Tier: Distributes incoming network traffic across
multiple servers to ensure high availability and responsiveness.
Security Tier: Firewalls, intrusion detection systems.
o Advantages:
Scalability: Each tier can be scaled independently, allowing for better
resource allocation. You can add more web servers, application
servers, or database servers as needed.
Reliability/Availability: Failure in one tier is less likely to bring down
the entire system. Load balancing and redundancy can be easily
implemented.
Maintainability: Easier to update, modify, or troubleshoot individual
components without affecting the entire application due to clear
separation of concerns.
Security: Improved security as direct access to sensitive tiers (like the
database) is restricted to specific intermediate tiers.
Flexibility: Allows for the use of different technologies for different
tiers, optimizing performance for specific tasks.
Performance: Can improve performance by distributing workload
and optimizing resource usage.
o Disadvantages:
Complexity: More complex to design, develop, and manage due to
distributed components and inter-tier communication.
Increased Latency: Communication between multiple tiers can
introduce network latency.
Cost: Can be more expensive due to the need for more servers and
infrastructure.
Debugging: Troubleshooting issues can be more challenging due to
the distributed nature of the system.
3. Discuss architectural issues of the web layer. The web layer (often the presentation
tier or the web server aspect of multi-tier architecture) faces several architectural
challenges:
o Scalability: How to handle increasing numbers of concurrent users and
requests without performance degradation. This involves strategies like load
balancing, caching, and horizontal scaling of web servers.
o Performance: Ensuring fast response times for users. Issues include slow
rendering, large asset sizes, unoptimized code, and inefficient server
configurations.
o Security: Protecting against common web vulnerabilities like Cross-Site
Scripting (XSS), SQL Injection, Cross-Site Request Forgery (CSRF), session
hijacking, and denial-of-service (DoS) attacks. Proper input validation,
output encoding, secure session management, and robust
authentication/authorization are critical.
CREATED BY: AARYAN JHA
1. What is XML? Write rules to create a well-formed XML document with example.
XML (Extensible Markup Language) is a markup language designed to store and
transport data. It is self-descriptive and defines a set of rules for encoding
documents in a format that is both human-readable and machine-readable.
o Rules for a Well-Formed XML Document:
1. Root Element: Every XML document must have exactly one root
element.
2. Properly Nested Elements: Elements must be properly nested (e.g.,
<outer><inner></inner></outer> is correct,
<outer><inner></outer></inner> is incorrect).
3. Case-Sensitive Tags: XML tags are case-sensitive (e.g., <book> is
different from <Book>).
4. Closing Tags: Every opening tag must have a corresponding closing
tag, or be an empty-element tag (e.g., <element/>).
5. Valid Characters: Element names and attribute names must follow
XML naming rules (cannot start with xml (case-insensitive), cannot
contain spaces, etc.).
6. Attribute Values in Quotes: All attribute values must be enclosed in
single or double quotes.
7. Prolog (Optional but Recommended): The XML declaration <?xml
version="1.0" encoding="UTF-8"?> is optional but highly
recommended as the first line.
o Example of a Well-Formed XML Document:
XML
CREATED BY: AARYAN JHA
<?xml version="1.0" encoding="UTF-8"?>
<students>
<student id="101">
<name>John Doe</name>
<major>Computer Science</major>
</student>
<student id="102">
<name>Jane Smith</name>
<major>Electrical Engineering</major>
</student>
</students>
2. Differentiate between XML Schema (XSD) and DTD. Both DTD (Document Type
Definition) and XML Schema (XSD) are used to define the structure and content of
XML documents, but they have key differences.
| | Syntax | Non-XML syntax; uses its own unique syntax. | XML-based syntax; XML
itself. |
| Data Types | Limited basic data types (e.g., PCDATA, CDATA). | Rich set of built-
in data types (e.g., string, integer, boolean, date, time) and allows custom data types.
|
| Readability | Can be less readable due to its unique syntax. | More readable for
XML developers as it uses XML syntax. |
| Ease of Use | Simpler for very basic XML structures. | More complex for simple
structures, but powerful for complex ones. |
| Learning Curve | Quicker to learn for basic use. | Steeper learning curve due to its
extensive features. |
3. Write XML and XSD to store student or visitor information with validations (e.g.,
10-digit phone number, department list).
(For your exam, you should be prepared to write both the XML and XSD. This task
involves creating and validating XML with DTD and XSD.)
CREATED BY: AARYAN JHA
XML
XML
<xs:element name="students">
<xs:complexType>
<xs:sequence>
<xs:element name="student" type="studentType"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="studentType">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="email" type="xs:string"/>
<xs:element name="phone" type="phoneType"/> <xs:element
name="department" type="departmentType"/> </xs:sequence>
<xs:attribute name="id" type="xs:ID" use="required"/>
</xs:complexType>
<xs:simpleType name="phoneType">
<xs:restriction base="xs:string">
<xs:pattern value="\d{10}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="departmentType">
<xs:restriction base="xs:string">
<xs:enumeration value="Computer Science"/>
CREATED BY: AARYAN JHA
<xs:enumeration value="Electrical Engineering"/>
<xs:enumeration value="Mechanical Engineering"/>
<xs:enumeration value="Civil Engineering"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
4. What is XPath? Write an XSLT document to filter and sort XML data. XPath
(XML Path Language) is a language for finding information in an XML document.
It is used to navigate through elements and attributes in an XML document.
(For your exam, you should be prepared to write an XSLT document. This task
involves transforming XML using XSLT and using XPath to query XML data.)
XML
XML
<xsl:template match="/students">
<html>
<head>
<title>Filtered and Sorted Students</title>
</head>
<body>
<h1>Computer Science Students (Sorted by Name)</h1>
<ul>
<xsl:for-each select="student[major = 'Computer
Science']">
<xsl:sort select="name" order="ascending"/>
<li>
<xsl:value-of select="name"/> (<xsl:value-
of select="age"/> years old)
</li>
</xsl:for-each>
</ul>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
o Explanation:
select="student[major = 'Computer Science']": This XPath
expression filters for <student> elements where the child element
major has the text content "Computer Science".
<xsl:sort select="name" order="ascending"/>: This XSLT
instruction sorts the selected student nodes based on the name element
in ascending alphabetical order.
5. Explain XSL/XSLT and how they are used to transform XML. XSL (eXtensible
Stylesheet Language) is a family of recommendations for transforming and
presenting XML documents. It consists of three parts:
o XSLT (XSL Transformations): Used for transforming XML documents.
o XPath (XML Path Language): Used by XSLT to navigate and select nodes in
an XML document.
o XSL-FO (XSL Formatting Objects): Used for formatting XML documents
for output (e.g., PDF, print).
1. Source XML Document: The input XML data that needs to be transformed.
2. XSLT Stylesheet: An XML document containing transformation rules. These
rules are defined using XSLT elements and XPath expressions.
CREATED BY: AARYAN JHA
In essence, XSLT allows you to convert the structure and content of one XML
document into a completely different structure or format, making XML highly
versatile for data exchange and presentation.
2. Describe the difference between SAX and DOM parsers. SAX (Simple API for
XML) and DOM (Document Object Model) are two common types of parsers used
to process XML documents. They differ fundamentally in how they load and
represent the XML data in memory.
3. Export to Sheets
4. What are order indicators and occurrence indicators in XML Schema? XML
Schema (XSD) uses order indicators and occurrence indicators to define the
expected sequence and number of times child elements can appear within a complex
type.
CREATED BY: AARYAN JHA
o Order Indicators:
These define the allowed order of child elements within a complex type.
These define how many times a particular element or group of elements can
appear. They are attributes applied to <xs:element>, <xs:group>, or
<xs:any>.
1. What is a web server? Explain its main functions with examples. A web server is a
computer program that stores web content (like HTML pages, images, CSS files,
JavaScript files) and delivers it to web browsers or other client applications upon
request. It uses the Hypertext Transfer Protocol (HTTP) to communicate with
clients.
o Main Functions:
1. Serving Static Content: The most basic function. When a browser
requests a static file (e.g., an HTML file, an image, a CSS stylesheet),
the web server locates the file on its storage and sends it back to the
browser.
Example: A user types www.example.com/index.html into
their browser. The web server receives the request, finds
index.html on its file system, and sends it back to the user's
browser.
2. Handling HTTP Requests and Responses: It constantly listens for
incoming HTTP requests on a specific port (usually 80 for HTTP, 443
for HTTPS). Once a request is received, it processes it and sends back
an HTTP response, which includes the requested content and status
codes (e.g., 200 OK, 404 Not Found).
Example: A browser sends a GET /image.png HTTP/1.1
request. The server responds with HTTP/1.1 200 OK and the
binary data of image.png.
3. Executing Server-Side Scripts: For dynamic content, web servers
often work with application servers or have built-in modules to
execute server-side scripts (e.g., PHP, Python, Node.js, ASP.NET).
The script generates HTML, which the web server then sends to the
client.
Example: A user fills out a login form. The web server receives
the form data, passes it to a PHP script. The PHP script
processes the data (e.g., checks credentials against a database),
and generates an HTML response (e.g., a "Welcome" page or
an "Invalid Login" message), which the web server sends back.
4. Security (Basic Level): Web servers provide basic security features
like access control (restricting access to certain directories or files
based on IP address or authentication), and support for HTTPS
(SSL/TLS encryption) to secure data in transit.
Example: Configuring the web server to only allow access to an
administration panel from specific IP addresses.
CREATED BY: AARYAN JHA
5. Logging: Web servers maintain access logs that record details about
every request, such as the client's IP address, the requested URL, the
time of the request, and the response status. These logs are crucial for
monitoring, debugging, and security analysis.
Example: An entry in an Apache access log might look like:
192.168.1.1 - - [21/Jul/2025:10:00:00 +0000] "GET
/index.html HTTP/1.1" 200 1234.
2. What is a session? Explain session management with server-side script example. A
session in web technology refers to a period of interaction between a user and a web
application. Since HTTP is a stateless protocol (meaning each request is
independent of the previous one), sessions are crucial for maintaining user state
across multiple page requests. This allows the server to "remember" a user's
activities, such as being logged in, items in a shopping cart, or preferences.
1. Session Creation: When a user first interacts with the web application
(e.g., logs in), the server generates a unique session ID.
2. Session ID Transmission: This session ID is then sent back to the
client, usually embedded in a cookie. The cookie is stored on the
client's browser.
3. Subsequent Requests: For every subsequent request, the browser
automatically sends the session ID cookie back to the server.
4. Session Data Retrieval: The server uses this session ID to retrieve the
associated session data (stored on the server-side, e.g., in memory, a
file, or a database). This data can include user ID, login status,
shopping cart contents, etc.
5. Session Expiration: Sessions typically have an expiration time (e.g., 30
minutes of inactivity) or can be explicitly destroyed when a user logs
out.
(This example provides a conceptual overview, as direct runnable code for a specific
language is beyond the scope of this format. The task involves writing server-side
scripts for session handling.)
PHP
<?php
session_start(); // Start the session or resume existing one
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$username = $_POST['username'];
$password = $_POST['password'];
PHP
<?php
session_start(); // Resume the session
PHP
<?php
session_start(); // Start the session to access its data
(For your exam, you should be prepared to outline the steps and show conceptual
code. This task involves writing scripts to insert form data into a database.)
HTML
PHP
<?php
// 1. Database Configuration
$servername = "localhost";
$username = "db_user";
$password = "db_password";
$dbname = "my_database";
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error); //
}
How it works:
1. Client Request: A user's browser sends an HTTP request to the web server
for a dynamic page (e.g., products.php, userprofile.asp).
2. Server-Side Script Execution: The web server recognizes that the requested
resource is a server-side script (e.g., PHP, Python, Ruby, Node.js, ASP.NET).
It then passes the request to the appropriate
3. Data Processing: The server-side script executes. During its execution, it can
perform various operations:
Access Databases: Retrieve data from databases (e.g., product lists,
user profiles, blog posts).
Process User Input: Handle data submitted through HTML forms
(e.g., login credentials, search queries, contact messages).
Perform Calculations: Execute business logic, calculations, or data
transformations.
Interact with External APIs: Fetch data from other web services (e.g.,
weather APIs, payment gateways).
CREATED BY: AARYAN JHA
3. What are tag libraries? Explain with examples. Tag libraries (also known as custom
tags or custom tag extensions) are collections of predefined actions (tags) that extend
the functionality of a server-side scripting language or templating engine. They
allow developers to encapsulate complex logic into simple, reusable XML-like tags,
making web page development cleaner, more efficient, and easier to maintain by
separating presentation from business logic.
Instead of embedding large blocks of scripting code directly into HTML, developers
can use a custom tag that performs that complex operation. The server-side
environment (e.g., a JSP container, a templating engine) recognizes these tags and
executes the associated code.
o Key Benefits:
Separation of Concerns: Helps keep presentation logic (HTML)
distinct from business logic (server-side code).
CREATED BY: AARYAN JHA
Instead of:
Java
<%
List<String> items = (List<String>)
request.getAttribute("items");
for (String item : items) {
out.println("<li>" + item + "</li>");
}
%>
You use:
Java
HTML
CREATED BY: AARYAN JHA
<%@ taglib prefix="form"
uri="http://www.springframework.org/tags/form" %>
<form:form modelAttribute="user" action="saveUser">
Name: <form:input path="name"/><br/>
Email: <form:input path="email"/><br/>
<input type="submit" value="Save"/>
</form:form>
While not strictly "tag libraries" in the JSP sense, modern templating
engines like Thymeleaf use similar concepts by extending HTML with
special attributes that process server-side logic.
HTML
<ul xmlns:th="http://www.thymeleaf.org">
<li th:each="item : ${items}"
th:text="${item}"></li>
</ul>
In essence, tag libraries provide a more structured and manageable way to embed
dynamic behavior into web pages, shifting from imperative scripting directly in
HTML to a more declarative, component-based approach.
PHP
try {
// Code that might throw an exception (e.g., database
connection, file operation)
$db = new PDO('mysql:host=localhost;dbname=test',
'user', 'wrong_pass');
echo "Database connected!";
} catch (PDOException $e) {
// Catch a specific database exception
error_log("Database Error: " . $e->getMessage()); //
Log the error
echo "An error occurred during database connection.
Please try again later."; // User-friendly message
} catch (Exception $e) {
// Catch any other general exception
error_log("General Error: " . $e->getMessage()); //
echo "An unexpected error occurred.";
}
(This question has been largely covered in Unit 4, Q2 for sessions. Here, we'll briefly
recap for sessions and add a conceptual example for cookies. For your exam, you
should be prepared to write a login script using either method.)
While sessions (which often use cookies internally for the session ID) are generally
preferred for security, direct cookies can also store login status. However, storing
sensitive data like username/password directly in cookies is highly discouraged due
to security risks. This example demonstrates storing a login flag or a remember-me
token in a cookie.
login_cookie.php:
CREATED BY: AARYAN JHA
PHP
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$username = $_POST['username'];
$password = $_POST['password'];
$remember_me = isset($_POST['remember_me']);
header("Location: dashboard_cookie.php");
exit();
} else {
echo "Invalid username or password.";
}
}
?>
<!DOCTYPE html>
<html>
<head><title>Login with Cookie</title></head>
<body>
<form action="login_cookie.php" method="post">
Username: <input type="text" name="username"><br>
Password: <input type="password" name="password"><br>
<input type="checkbox" name="remember_me"> Remember Me<br>
<input type="submit" value="Login">
</form>
</body>
</html>
dashboard_cookie.php:
PHP
<?php
// Check if the 'user_logged_in' cookie exists and is true
if (!isset($_COOKIE['user_logged_in']) || $_COOKIE['user_logged_in']
!== "true") {
header("Location: login_cookie.php"); // Redirect to login if not
logged in
CREATED BY: AARYAN JHA
exit();
}
$username = isset($_COOKIE['username_cookie']) ?
htmlspecialchars($_COOKIE['username_cookie']) : 'Guest';
?>
<!DOCTYPE html>
<html>
<head><title>Dashboard (Cookie)</title></head>
<body>
<h1>Welcome, <?php echo $username; ?>!</h1>
<p>This is your personalized dashboard content from cookies.</p>
<a href="logout_cookie.php">Logout</a>
</body>
</html>
logout_cookie.php:
PHP
<?php
// Unset/delete cookies by setting their expiration to a past time
setcookie("user_logged_in", "", time() - 3600, "/");
setcookie("username_cookie", "", time() - 3600, "/");
header("Location: login_cookie.php");
exit();
?>
Note: While using cookies directly for simple flags or "remember me" functionality
is common, storing sensitive user data directly in cookies is not recommended due to
client-side accessibility and potential for manipulation. Sessions are generally more
secure for storing user state.
2. Develop a simple web page that takes user input and stores it into a database.
(This question is almost identical to Unit 4, Q3. The solution and explanation
provided there are fully applicable. For your exam, focus on the HTML form,
server-side script logic, database connection, validation, and SQL INSERT query
with prepared statements.)
Refer to Unit 4, Question 3 for the detailed explanation and conceptual code. Key
points for development:
1. Receive
CREATED BY: AARYAN JHA
$_POST data.
Cookies are small pieces of data that a server sends to a user's web browser. The
browser stores these cookies and sends them back to the same server with every
subsequent request. They are primarily used to remember stateful information or to
record the user's Browse activity (e.g., login status, shopping cart items, user
preferences, tracking).
o Key Characteristics:
Small Size: Typically a few kilobytes.
Domain-Specific: Sent only back to the domain that set them.
Expiration: Can have an expiration date (persistent cookies) or expire
when the browser closes (session cookies).
Security Concerns: Can be vulnerable if not handled correctly (e.g.,
storing sensitive data, XSS attacks). HTTPS (Secure flag) and
HttpOnly flag are crucial for security.
cookie_example.php:
PHP
<?php
// --- PART 1: Setting a Cookie ---
if (isset($_POST['set_cookie_submit'])) {
$cookie_name = "user_preference";
$cookie_value = "dark_mode";
$expiration_time = time() + (86400 * 30); // Cookie expires in 30
days (86400 seconds = 1 day)
if (isset($_COOKIE["last_visit"])) {
echo "<p>Last Visit (Session Cookie): " .
htmlspecialchars($_COOKIE["last_visit"]) . "</p>"; //
} else {
echo "<p>Session cookie 'last_visit' not set.</p>";
}
<h2>Delete Cookies</h2>
<form method="post">
<input type="submit" name="delete_cookie_submit" value="Delete
All Example Cookies">
</form>
</body>
</html>
(For your exam, you should be prepared to write these fundamental SQL
commands. This task involves connecting to databases and executing SQL
commands.)
Assume a table named Employees with columns: EmployeeID (Primary Key, INT),
FirstName (VARCHAR), LastName (VARCHAR), Department (VARCHAR),
Salary (DECIMAL).
1. SELECT (Retrieve Data): Used to retrieve data from one or more tables.
Select all columns from all rows:
SQL
SQL
SQL
CREATED BY: AARYAN JHA
SELECT FirstName, LastName FROM Employees WHERE Department
= 'Sales';
SQL
SQL
2. INSERT (Add New Data): Used to add new rows of data into a table.
Insert into all columns (values must be in column order):
SQL
SQL
SQL
UPDATE Employees
SET Salary = 80000.00
WHERE EmployeeID = 101;
SQL
UPDATE Employees
SET Salary = Salary * 1.05 -- Increase salary by 5%
CREATED BY: AARYAN JHA
WHERE Department = 'Sales';
Caution: Always use a WHERE clause with UPDATE unless you intend to
update all rows.
4. DELETE (Remove Data): Used to remove one or more rows from a table.
Delete a single row (using WHERE clause):
SQL
SQL
SQL
Caution: Always use a WHERE clause with DELETE unless you intend to
delete all rows.
2. What is anonymous access? Discuss Integrated Windows Authentication. These are
two different authentication methods for web servers, particularly relevant in
Windows environments like IIS (Internet Information Services).
o Anonymous Access:
Concept: Allows users to access public areas of a web server or
application without providing any credentials (username or
password). The server treats all anonymous requests as if they came
from a special, built-in anonymous user account (e.g.,
IUSR in IIS).
Differentiation Summary:
o HTTP Methods: Forms typically submit data using GET or POST HTTP
methods.
CREATED BY: AARYAN JHA
GET: Appends form data to the URL as query parameters. Suitable for
simple queries, non-sensitive data, and when users might bookmark
results. Data is visible in the URL and limited in size.
POST: Sends form data in the body of the HTTP request. Suitable for
sensitive data (passwords), large amounts of data (file uploads), and
data that modifies the server state. Data is not visible in the URL.
o Retrieving Data: Server-side languages provide superglobal arrays or similar
mechanisms to access submitted data.
PHP: $_GET for GET requests, $_POST for POST requests, and
$_REQUEST for both.
Python (Flask): request.args for GET, request.form for POST.
Node.js (Express): req.query for GET, req.body for POST (requires
body-parser middleware).
o Validation and Sanitization: Crucial for security and data integrity.
Validation: Checking if data meets expected criteria (e.g., email
format, numeric input, required fields).
Sanitization: Cleaning data to remove potentially harmful characters
or code (e.g., HTML tags to prevent XSS, special characters to
prevent SQL injection).
Example: htmlspecialchars() in PHP to prevent XSS when
displaying user input. Using prepared statements for database
interactions.
o Processing Data: After retrieval, validation, and sanitization, the data can be
processed:
Storing in a database.
Sending emails.
Generating dynamic content.
Performing calculations.
o File Uploads:
HTML
2. Server-Side Script:
CREATED BY: AARYAN JHA
Proper handling of form data and files on the server-side involves robust validation,
sanitization, secure storage practices, and appropriate error handling to protect the
application from vulnerabilities and ensure data integrity.