0% found this document useful (0 votes)
11 views51 pages

Web Tech Notes

The document provides an overview of web technologies, detailing the Internet's definition, history, and characteristics, as well as the World Wide Web's architecture and components. It explains web browsers, URLs, MIME, HTTP protocol, and HTML, including their features, limitations, and common tags. Additionally, it discusses HTML forms, CSS, and the different methods of applying CSS to HTML.

Uploaded by

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

Web Tech Notes

The document provides an overview of web technologies, detailing the Internet's definition, history, and characteristics, as well as the World Wide Web's architecture and components. It explains web browsers, URLs, MIME, HTTP protocol, and HTML, including their features, limitations, and common tags. Additionally, it discusses HTML forms, CSS, and the different methods of applying CSS to HTML.

Uploaded by

jatingaur39
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Unit-I: Introduction to Web Technologies

Q1. Explain the Internet in detail. Discuss its history and characteristics. (PYQ)

Answer: Definition: The Internet ("Inter-connected Network") is a massive global system of


interconnected computer networks that use the standard TCP/IP (Transmission Control
Protocol/Internet Protocol) suite to serve billions of users worldwide. It is a physical
infrastructure consisting of cables, routers, switches, and satellites that connects private,
public, academic, business, and government networks.

History of the Internet (Timeline):

1. 1969 (ARPANET): The Advanced Research Projects Agency (ARPA) of the US Defense
Department commissioned ARPANET. The first connection was established between
UCLA and Stanford. It introduced Packet Switching technology.

2. 1970s (TCP/IP): Vint Cerf and Bob Kahn developed the TCP/IP protocols, creating a
standard way for different networks to talk to each other.

3. 1983: ARPANET officially adopted TCP/IP, marking the birth of the modern "Internet."

4. 1986 (NSFNET): The National Science Foundation created a high-speed backbone


connecting supercomputing centers, opening the network to academic researchers.

5. 1991 (WWW): Tim Berners-Lee released the World Wide Web, making the Internet
user-friendly with browsers and pages.

6. 1990s (Commercialization): Internet Service Providers (ISPs) emerged, bringing the


Internet to homes and businesses.

Characteristics:

1. Decentralized: There is no single controlling authority or central computer. If one


node fails, data routes around it.

2. Packet Switching: Data is broken into small "packets," sent independently over the
most efficient routes, and reassembled at the destination.

3. Protocol-Based: Relies on standardized protocols (IP, TCP, UDP, DNS) to ensure


diverse devices can communicate.

4. Scalability: The architecture allows millions of new devices to be added without


redesigning the core system.

5. Platform Independent: It connects varied hardware (PCs, Phones, Servers) and


Operating Systems (Windows, Linux, macOS).
Q2. What is the World Wide Web (WWW)? Explain its working and components. (VERY
HIGH PYQ)

Answer: Definition: The World Wide Web (WWW), or "The Web," is a system of interlinked
hypertext documents and multimedia resources accessed via the Internet. While the
Internet is the hardware (roads), the Web is the service (traffic) that runs on top of it.

Architecture (Client-Server Model): The Web operates on a Request-Response model:

 Client: The browser (Chrome, Edge) requests a page.

 Server: The remote computer (Apache, Nginx) sends the page.

Core Components:

1. URL (Uniform Resource Locator): The unique address of a specific resource (e.g.,
[Link]

2. HTTP (HyperText Transfer Protocol): The language clients and servers use to talk. It
defines methods like GET (fetch data) and POST (send data).

3. HTML (HyperText Markup Language): The standard format for structuring


documents.

4. Web Server: Software that stores website files and handles incoming requests.

5. Web Browser: Software that interprets HTML/CSS and renders the visible page.

Working Steps:

1. User Input: User types a URL.

2. DNS Resolution: The browser converts the domain name ([Link]) into an IP
address ([Link]) using a DNS Server.

3. Connection: Browser opens a TCP connection to the Web Server.

4. Request: Browser sends an HTTP GET request.

5. Response: Server sends back the HTML file (HTTP 200 OK).

6. Rendering: Browser parses HTML, fetches linked CSS/Images, and displays the page.

Q3. Explain Web Browsers. Describe their evolution and functions. (PYQ)

Answer: Definition: A Web Browser is a software application used to locate, retrieve, and
display content on the World Wide Web. It acts as the interface between the user and the
Web Server.
Internal Architecture: A browser consists of a User Interface (Address bar, buttons), a
Rendering Engine (to parse HTML/CSS), a JavaScript Engine (to execute code), and
Networking components.

Functions:

1. Rendering: Converts raw HTML and CSS code into a visual representation (The DOM
Tree).

2. Networking: Handles HTTP/HTTPS requests and manages DNS lookups.

3. Storage: Manages local data like Cookies, Cache, and Local Storage for faster loading
and session management.

4. Security: Implements "Sandboxing" to prevent malicious code from accessing the


user's OS and verifies SSL certificates.

Evolution:

 Generation 1 (1990-1993): WorldWideWeb (text-only) and Mosaic (first to show


images inline).

 Generation 2 (1994-2000): Netscape Navigator vs. Internet Explorer (IE). Microsoft


won the "Browser Wars" by bundling IE with Windows.

 Generation 3 (2004-2008): Mozilla Firefox launched with tabbed browsing and pop-
up blocking, challenging IE's monopoly.

 Generation 4 (2008-Present): Google Chrome launched with the V8 JS engine


(extremely fast). Today, Chrome, Safari, and Edge (Chromium-based) dominate.

Q4. Explain URL in detail. Describe its structure and types. (PYQ)

Answer: Definition: A Uniform Resource Locator (URL) is a standardized text string used to
identify and locate a resource (web page, image, video) on the Internet. It serves as the
"address" for the browser.

Structure of a URL: scheme://domain:port/path?query_string#fragment_id

1. Scheme (Protocol): Tells the browser how to fetch the resource.

o [Link] Unsecured web.

o [Link] Secured web (Encrypted).

o [Link] File Transfer.

o [Link] Email.

2. Domain Name: The human-readable name of the server (e.g., [Link]).


3. Port: The technical gate number (default is 80 for HTTP, 443 for HTTPS). Usually
hidden.

4. Path: The specific file location on the server (e.g., /electronics/phones).

5. Query String: Data passed to the server, starting with ? (e.g., ?product_id=55).

6. Fragment: Points to a specific section within the page, starting with # (e.g.,
#reviews).

Types of URLs:

1. Absolute URL: Contains the full address, including protocol and domain. Used for
linking to external sites.

o Ex: [Link]

2. Relative URL: Describes the location relative to the current page. Used for internal
links.

o Ex: ../images/[Link] (Go up one folder, look in images).

Q5. What is MIME? Explain its role in web communication. (PYQ)

Answer: Definition: MIME (Multipurpose Internet Mail Extensions) is an Internet standard


that extends the original email protocol to support non-ASCII text, audio, video, images, and
application files. In the Web context, it tells the browser "what kind of file this is."

Role in Web Communication: When a web server sends a file to a browser, it includes a
Content-Type header (MIME type). This is crucial because file extensions (like .jpg) might be
missing or wrong.

 The browser reads the MIME type to decide which plugin or helper application to
use.

MIME Type Format: type/subtype

Common MIME Examples:

 Text: text/html (Web pages), text/css (Stylesheets), text/plain (Raw text).

 Images: image/jpeg, image/png, image/gif.

 Audio/Video: audio/mpeg (MP3), video/mp4.

 Applications: application/pdf (Adobe PDF), application/json (Data),


application/javascript (JS code).

Example: If a server sends a file with content-type: application/pdf, the browser knows to
launch its PDF viewer, not display it as text.
Q6. Explain HTTP protocol in detail. Mention its features and limitations. (VERY HIGH PYQ)

Answer: Definition: HTTP (HyperText Transfer Protocol) is the application-layer protocol


that powers the World Wide Web. It defines the format of messages exchanged between a
Client (Browser) and a Server.

Working Principle: It follows a Request-Response cycle.

 Client Request: Method URL Version (e.g., GET /[Link] HTTP/1.1).

 Server Response: Version Status-Code (e.g., HTTP/1.1 200 OK).

Key Features:

1. Connectionless: The client disconnects after the request is fulfilled. It does not hold
the line open (in HTTP/1.0).

2. Media Independent: Can transfer any data type (text, video, zip) as long as the MIME
type is specified.

3. Stateless: The server does not remember the client. If you request page 1 and then
page 2, the server doesn't know you are the same person (unless Cookies are used).

Limitations:

1. No Security: HTTP sends data in Plain Text. Hackers can sniff passwords. (Solution:
Use HTTPS with SSL/TLS encryption).

2. Statelessness: Makes building interactive apps (like Shopping Carts) difficult without
using Cookies/Sessions.

3. Performance: Loading a page with 100 images requires 100 separate requests
(Solution: HTTP/2 Multiplexing).

Q7. Explain Web Programmer’s Toolbox. (PYQ)

Answer: A "Web Programmer's Toolbox" consists of the core technologies, languages, and
software needed to build modern web applications. It is categorized into three layers:
Shutterstock

Explore

1. The Presentation Layer (Front-End):

 HTML: Defines the structure (Semantic markup).

 CSS: Defines the look and feel (Layout, Colors, Responsive design).

 JavaScript: Implements logic and interactivity (DOM manipulation).

 Frameworks: React, Angular, [Link] (for complex UIs).

2. The Logic Layer (Back-End/Server-Side):

 Server-Side Scripts: Process data, handle logic, and talk to databases.

o Languages: PHP, Python (Django/Flask), [Link] (JS), Java (Spring).


 Web Server Software: Apache, Nginx (Host the application).

3. The Data Layer (Database):

 SQL: MySQL, PostgreSQL (Structured data).

 NoSQL: MongoDB (Unstructured data/JSON).

4. Helper Tools:

 Git: Version control.

 Browser DevTools: For debugging and testing.

 AJAX/Fetch API: For asynchronous data loading.

Q8. Explain HTML in detail. What are its features and limitations? (VERY HIGH PYQ)

Answer: Definition: HTML (HyperText Markup Language) is the standard skeleton of the
web. It is a Markup Language, not a programming language, meaning it uses "Tags" to
annotate text to tell the browser how to structure it.

Structure: An HTML document is a tree of elements.

HTML

<!DOCTYPE html>

<html>

<head><title>My Page</title></head>

<body><h1>Hello World</h1></body>

</html>

Features:

1. Platform Independent: Runs on any device with a browser.

2. Hyperlinking: The <a> tag connects the world's information.

3. Semantic Elements: HTML5 introduced tags like <nav>, <article>, <section> which
describe what the content is, not just how it looks.

4. Multimedia: Native support for <audio> and <video> without plugins (Flash is dead).

Limitations:

1. Static: Cannot display dynamic data (like current time or stock prices) without
JavaScript.
2. No Logic: Cannot perform calculations (2+2) or logic (If-Else).

3. Security: HTML code is visible to anyone ("View Source"), so it cannot store secrets.

Q9. Explain HTML Common Tags with examples. (VERY HIGH PYQ)

Answer: HTML tags are keywords enclosed in < > brackets. They usually come in pairs: a
Start Tag and an End Tag (e.g., <b>...</b>).

Categories of Common Tags:

1. Document Structure:

o <html>: Root of the document.

o <head>: Container for metadata (CSS links, title).

o <body>: Container for visible content.

2. Text Formatting:

o <h1> to <h6>: Headings (H1 is the most important).

o <p>: Paragraph (automatically adds spacing).

o <strong> / <b>: Bold text.

o <em> / <i>: Italic text.

3. Lists:

o <ul>: Unordered List (Bullet points).

o <ol>: Ordered List (Numbers 1, 2, 3).

o <li>: List Item (used inside ul/ol).

4. Media & Links:

o <a href="URL">: Anchor tag for hyperlinks.

o <img src="URL" alt="text">: Embeds an image (Self-closing tag).

5. Tables:

o <table>: Wraps the table.

o <tr>: Table Row.

o <th>: Table Header (Bold and centered).

o <td>: Table Data (Regular cell).


Q10. Explain HTML Forms and Form Controls in detail. (VERY HIGH PYQ)

Answer: Definition: HTML Forms are the primary mechanism for collecting user input
(Registration, Search, Login) and sending it to a server for processing.

The <form> Container:

 action="url": Where to send the data.

 method="GET/POST": How to send the data.

o GET: Appends data to URL (Visible, fast, limited size).

o POST: Sends data in body (Invisible, secure, no size limit).

Common Form Controls:

1. Text Input: <input type="text"> for names/usernames.

2. Password: <input type="password"> masks characters as dots.

3. Radio Buttons: <input type="radio" name="gender"> allows selecting only one


option from a group.

4. Checkboxes: <input type="checkbox"> allows selecting multiple options.

5. Dropdowns: <select> with <option> creates a compact list.

6. Textarea: <textarea> for multi-line comments.

7. Buttons: <input type="submit"> sends the form; <input type="reset"> clears it.

Example:

HTML

<form action="/submit-data" method="POST">

Name: <input type="text" name="fname"><br>

<input type="submit" value="Send">

</form>

Q11. Explain Cascading Style Sheets (CSS). Why is it required? (VERY HIGH PYQ)

Answer: Definition: CSS (Cascading Style Sheets) is a stylesheet language used to describe
the presentation (look and formatting) of a document written in HTML.
The "Cascading" Nature: Styles can "cascade" or flow from one source to another. If
multiple styles conflict, the browser uses a priority scheme (Inline > Internal > External >
Browser Default).

Why is CSS Required? (Advantages):

1. Separation of Content and Design: HTML handles "What it is" (Structure), CSS
handles "How it looks" (Style). This makes code cleaner.

2. Global Changes: You can change the font of an entire 100-page website by modifying
one line in a single external CSS file.

3. Responsive Design: CSS Media Queries (@media) allow pages to adapt their layout
for Phones, Tablets, and Desktops.

4. Bandwidth Efficiency: CSS files are cached by the browser, speeding up load times
for subsequent pages.

Syntax: Selector { Property: Value; }

 Ex: p { color: red; font-size: 14px; }

Q12. Explain Types of CSS in detail. (PYQ)

Answer: There are three methods to apply CSS to HTML:

1. Inline CSS:

 Written directly inside the HTML tag using the style attribute.

 Pros: Good for quick, one-off changes.

 Cons: Makes HTML messy; impossible to maintain for large sites.

 Example: <h1 style="color: blue;">Heading</h1>

2. Internal (Embedded) CSS:

 Written inside a <style> tag within the <head> section of the HTML file.

 Pros: Good for single-page documents.

 Cons: Styles cannot be reused on other pages.

 Example:

HTML

<style>

body { background-color: lightgray; }


</style>

3. External CSS:

 Written in a separate .css file and linked using the <link> tag.

 Pros: Best practice. Allows reuse across thousands of pages. Cleanest HTML.

 Cons: Requires an extra HTTP request (minimal impact).

 Example: <link rel="stylesheet" href="[Link]">

Q13. Explain JavaScript and its role in web development. (VERY HIGH PYQ)

Answer: Definition: JavaScript (JS) is a high-level, interpreted, dynamic programming


language. It is the only language that runs natively inside web browsers, making it the
"language of the web."

Role in Web Development:

1. Client-Side Scripting: JS runs on the user's computer, not the server. This reduces
server load and makes apps feel instant.

2. DOM Manipulation: JS can Change, Add, or Delete HTML elements and CSS styles on
the fly.

o Ex: Switching from "Dark Mode" to "Light Mode" without reloading.

3. Form Validation: Validates inputs (e.g., checking if passwords match) before sending
data to the server.

4. Asynchronous Requests (AJAX): JS can fetch data (like new tweets or emails) in the
background without refreshing the whole page.

5. Web APIs: Accesses device hardware like Geolocation, Camera, and Microphone.

Evolution: Originally just for simple animations, modern JS ([Link]) allows full-stack
development (running JS on the server too).

Q14. Explain JavaScript variables, functions, and data types. (PYQ)

Answer: 1. Variables (Data Containers):

 var: The old way. Function-scoped. Can be redeclared.

 let: The modern way. Block-scoped. Can be updated but not redeclared.

 const: Constant. Block-scoped. Cannot be updated.


 Example: let score = 10; const pi = 3.14;

2. Data Types: JavaScript is dynamically typed (variables can hold any type).

 Primitive Types:

o String: Text ("Hello").

o Number: Integers or Decimals (100, 99.9).

o Boolean: Logic (true, false).

o Undefined: Variable declared but not assigned.

o Null: Empty value.

 Complex Types:

o Object: Collection of key-value pairs ({name: "John", age: 30}).

o Array: Ordered list ([1, 2, 3]).

3. Functions: Blocks of reusable code.

 Definition: function add(a, b) { return a + b; }

 Call: let result = add(5, 10);

Q15. Explain Event Handling in JavaScript. (VERY HIGH PYQ)

Answer: Definition: JavaScript is an Event-Driven language. An Event is an action that occurs


in the browser (User clicks, Key press, Page loads). Event Handling is the code that "listens"
for these events and executes logic when they happen.

Mechanisms to Handle Events:

1. Inline Event Handler (HTML Attribute):

o <button onclick="alert('Clicked!')">Click Me</button>

o Simple but mixes HTML and JS.

2. DOM Property (JS Code):

o [Link]("btn").onclick = function() { ... };

3. Event Listener (Best Practice):

o [Link]("click", functionName);

o Allows adding multiple events to one element.

Common Events:
 Mouse: click, dblclick, mouseover, mouseout.

 Keyboard: keydown, keyup.

 Form: submit, change, focus.

 Window: load, resize, scroll.

Q16. Explain Form Validation using JavaScript. (VERY HIGH PYQ)

Answer: Definition: Form Validation is the process of checking input data against a set of
rules before letting the user submit the form.

Why Use JS Validation?

 User Experience: Gives instant feedback (e.g., "Password too short") without waiting
for a server reload.

 Security: Prevents malicious code injection (Basic level).

 Data Integrity: Ensures databases receive clean, standardized data.

Validation Techniques:

1. Empty Check: if (name == "") { alert("Name required"); }

2. Format Check (RegEx): Using Regular Expressions to validate patterns (e.g., Email
address structure).

o Ex: var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;

3. Logic Check: Ensuring "Confirm Password" matches "Password".

Example Code:

JavaScript

function validate() {

let age = [Link]("age").value;

if (isNaN(age) || age < 18) {

alert("Must be 18+");

return false; // Stop submission

return true; // Allow submission

}
Unit-II: XML & PHP

Q1. What is XML? Write its features and applications. (PYQ – VERY FREQUENT)

Answer:

Definition:

XML (eXtensible Markup Language) is a text-based markup language derived from SGML. It
is designed to store, transport, and describe data, rather than to display it. Unlike HTML,
XML tags are not predefined; users must define their own tags to create a self-descriptive
structure.

Features of XML:

1. Extensible: Users can define their own tags (e.g., <student>, <salary>), allowing for
customized data structures.

2. Self-Descriptive: The tags describe the data they contain. For example,
<price>200</price> clearly indicates the value represents a price.

3. Platform Independent: XML is stored as plain text, making it readable by any


operating system or programming language.

4. Hierarchical Structure: It organizes data in a strict tree structure (Parent-Child


relationship), making it easy to parse.

5. Separation of Concerns: It separates data (XML) from presentation (XSLT/CSS).

Applications of XML:

 Data Exchange: Standard format for transferring data between incompatible systems
(e.g., Java to Python).

 Web Services: Used in SOAP and REST APIs to carry message payloads.

 Configuration Files: Used by software frameworks (e.g., Android


[Link], Spring Boot) to store settings.

 Database Storage: Native XML databases (NXD) store data directly in XML format.

Q2. Differentiate between HTML and XML. (PYQ – DIRECT)

Answer:

Although both are markup languages, they serve fundamentally different purposes.
Feature HTML (HyperText Markup Language) XML (eXtensible Markup Language)

To display data and define document To store and transport data (Content &
Purpose
structure (Look & Feel). Context).

Predefined (e.g., <h1>, <table>). You User-defined (e.g., <book>, <author>).


Tags
cannot invent new ones. You create what you need.

Case Case insensitive (<BODY> is treated Strictly Case sensitive (<Name> is


Sensitivity as <body>). different from <name>).

Optional for some tags (e.g., <br>,


Closing Tags Mandatory for all tags.
<img>).

Lenient; browsers try to display even Strict; parser stops immediately if there
Syntax Check
with errors. is an error.

Dynamic Static layout. Dynamic data carrier.

Conclusion: HTML is about Presentation; XML is about Information.

Q3. Explain the structure of an XML document. (PYQ)

Answer:

An XML document must form a Tree Structure starting with a root element and branching
out to child elements.

Components:

1. Prolog (XML Declaration): The first line defining the XML version and encoding.

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

2. Root Element: The single parent tag that wraps the entire document. Every XML file
must have exactly one root.

o Example: <library> ... </library>

3. Child Elements: Nested tags containing data or other elements.

o Example: <book> inside <library>.

4. Attributes: Name-value pairs providing metadata about elements.

o Example: <book id="101">

Rules:

 Proper Nesting: Opened tags must be closed in reverse order (<b><i>Text</i></b>).


 Single Root: There cannot be two top-level elements.

 Quoted Attributes: Attribute values must be in quotes.

Q4. What is well-formed and valid XML? (PYQ – VERY HIGH)

Answer:

1. Well-Formed XML:

An XML document is "Well-Formed" if it adheres to the basic Syntax Rules of XML. If a


document is not well-formed, an XML parser will reject it.

 Conditions:

o Must have a single root element.

o All tags must be closed.

o Tags must be properly nested.

o Case sensitivity must be respected.

2. Valid XML:

An XML document is "Valid" if it is Well-Formed AND it conforms to a defined structure


(Grammar) defined in a DTD (Document Type Definition) or XML Schema.

 Conditions:

o It must follow the rules of the DTD/Schema (e.g., order of elements, data
types).

Relationship:

 All Valid XML documents are Well-Formed.

 Not all Well-Formed XML documents are Valid (they might violate the DTD).

Q5. What is DTD? Explain its types. (PYQ – VERY HIGH)

Answer:

Definition:

DTD (Document Type Definition) is a set of rules that defines the legal building blocks of an
XML document. It acts as a "contract" that defines the document structure with a list of legal
elements and attributes.

Types of DTD:
1. Internal DTD:

o The DTD rules are defined inside the XML file itself within the <!DOCTYPE>
wrapper.

o Usage: Best for small, independent XML files.

o Example:

XML

<!DOCTYPE note [

<!ELEMENT note (to,from,body)>

]>

2. External DTD:

o The rules are saved in a separate .dtd file and linked to the XML document.

o Usage: Best for standardization across multiple documents/organizations.

o Syntax: <!DOCTYPE root SYSTEM "[Link]">

Role: DTD ensures data consistency and validity before processing.

Q6. Explain DTD elements, attributes, and entities. (PYQ)

Answer:

DTD uses specific syntax to define the structure of XML.

1. Elements:

Defines what tags are allowed and what content they can contain.

 Syntax: <!ELEMENT element-name (content-model)>

 Example: <!ELEMENT student (name, roll_no)>

o Meaning: A <student> tag must contain a <name> and <roll_no>.

 PCDATA: "Parsed Character Data" (Text content).

2. Attributes:

Defines properties for elements.

 Syntax: <!ATTLIST element-name attr-name type default>

 Example: <!ATTLIST student id CDATA #REQUIRED>


o Meaning: The <student> tag must have an id attribute containing character
data.

3. Entities:

Defines shortcuts or special characters (like variables).

 Syntax: <!ENTITY name "value">

 Example: <!ENTITY copyright "Copyright 2024">

o Usage: Using &copyright; in XML will print "Copyright 2024".

Q7. What is XML Schema? How is it better than DTD? (PYQ)

Answer:

Definition:

XML Schema (XSD - XML Schema Definition) is a more powerful and flexible alternative to
DTD. It describes the structure of an XML document using XML syntax itself (unlike DTD
which uses a special non-XML syntax).

Advantages over DTD:

1. Data Types: XSD supports strong data typing (Integer, Date, Boolean, String). DTD
treats everything as text.

o Benefit: You can validate that "Age" is actually a number.

2. XML Syntax: XSD is written in XML, so you don't need to learn a new language to
write a schema. You can use standard XML parsers to parse the schema itself.

3. Namespaces: XSD supports XML Namespaces, allowing you to mix elements from
different schemas without name conflicts.

4. Extensibility: XSD supports object-oriented concepts like inheritance and extending


types.

Q8. What is XSL? Explain its components. (PYQ)

Answer:

Definition:

XSL (eXtensible Stylesheet Language) is a family of languages used to transform and render
XML documents. Since XML tags are user-defined, browsers don't know how to style them
(unlike HTML tags). XSL provides the styling and transformation rules.
Components of XSL:

1. XSLT (XSL Transformations): The most critical component. It is a language for


transforming XML documents into other formats like HTML, PDF, or text.

2. XPath (XML Path Language): A language for navigating through elements and
attributes in an XML document. It acts like a query language (finding specific nodes).

3. XSL-FO (XSL Formatting Objects): A language for specifying formatting semantics,


primarily used for generating PDFs or printed documents.

Q9. Explain XSLT with example. (PYQ – VERY HIGH)

Answer:

Definition:

XSLT (XSL Transformations) is a W3C standard used to convert XML into HTML so it can be
displayed in a browser. It works by matching XML elements against templates.

Working Principle:

1. Source: An XML document (Data).

2. Stylesheet: An XSLT file (Transformation Rules).

3. Processor: The XSLT processor applies rules to the source.

4. Result: A new document (usually HTML).

Example:

 XML: <title>Harry Potter</title>

 XSLT Code:

XML

<xsl:template match="/">

<html>

<body>

<h1><xsl:value-of select="title"/></h1>

</body>

</html>

</xsl:template>
 Output HTML: <h1>Harry Potter</h1>

Conclusion: XSLT maintains the separation of data (XML) and presentation (HTML).

Q10. Explain XPath. (PYQ)

Answer:

Definition:

XPath is a query language for selecting nodes from an XML document. It is a major element
in the XSLT standard. Without XPath, XSLT cannot find data to transform.

Features:

1. Path Expressions: It uses a directory-like path syntax.

o / selects the root node.

o // selects nodes anywhere in the document.

2. Predicates: Filters nodes based on specific conditions using [].

o Example: /bookstore/book[price>35] selects books costing more than 35.

3. Axes: Defines node relationships (ancestor, child, sibling, parent).

4. Functions: Includes standard functions for string, numeric, and boolean operations.

Q11. What is PHP? Write its features. (PYQ – VERY HIGH)

Answer:

Definition:

PHP (Hypertext Preprocessor) is a widely-used, open-source server-side scripting language


designed specifically for web development. It is embedded within HTML and executed on
the web server.

Features:

1. Server-Side Execution: The code runs on the server; the client (browser) receives
only plain HTML. The source code is secure and hidden from the user.

2. Database Integration: It has built-in support for almost all databases (MySQL,
PostgreSQL, Oracle), making it ideal for data-driven apps.

3. Platform Independent: PHP runs on Windows, Linux, Unix, and Mac servers.

4. Open Source: It is free to download and use, with a massive community.


5. Fast Performance: It is lightweight and executes faster than many other scripting
languages for web tasks.

Q12. Explain PHP architecture and working. (PYQ)

Answer:

Architecture (Client-Server Model):

PHP follows a 3-tier architecture:

1. Client (Browser): Initiates the request.

2. Server (Web Server + PHP Engine): Processes the logic.

3. Database: Stores the data.

Working Flow:

1. Request: The browser sends an HTTP request for a .php file (e.g., [Link]).

2. Interception: The Web Server (like Apache) recognizes the extension and forwards it
to the PHP Preprocessor (Engine).

3. Execution: The PHP Engine executes the script line-by-line. If database data is
needed, it queries the database.

4. Output Generation: The PHP script generates pure HTML output (stripping away all
PHP code).

5. Response: The Web Server sends the generated HTML back to the browser.
Shutterstock

Explore

Q13. Explain PHP variables, data types, and constants. (PYQ)

Answer:

1. Variables:

 Containers for storing data values.

 Syntax: Must start with a **$** sign (e.g., $name\).

 Loosely Typed: You do not need to declare the data type; PHP determines it
automatically based on the value.

2. Data Types:

 Scalar: String, Integer, Float (Double), Boolean.

 Compound: Array, Object.

 Special: NULL (empty), Resource (external reference).

3. Constants:

 Identifiers for values that cannot change during script execution.


 Syntax: Defined using define(). No $ sign is used.

 Example: define("PI", 3.14);

 Usage: echo PI; (Prints 3.14).

Q14. Explain PHP operators and control structures. (PYQ)

Answer:

1. Operators:

 Arithmetic: +, -, *, /, %

 Assignment: =, +=

 Comparison: == (Value check), === (Value & Type check), !=

 Logical: && (AND), || (OR), ! (NOT)

 String: . (Concatenation operator - joins strings).

2. Control Structures:

Manage the flow of execution in the script.

 Conditional Statements:

o if, else, elseif: Execute code based on conditions.

o switch: Selects one of many blocks of code.

 Loops:

o while: Loops while a condition is true.

o for: Loops a specific number of times.

o foreach: Specifically designed to loop through Arrays.

 Syntax: foreach ($array as $value) { ... }

Q15. Explain PHP arrays and functions. (PYQ – VERY HIGH)

Answer:

1. Arrays:

A special variable that can hold more than one value at a time.

 Indexed Arrays: Arrays with numeric keys (0, 1, 2).


o $cars = array("Volvo", "BMW");

o Access: $cars[0]

 Associative Arrays: Arrays with named keys.

o $age = array("Peter"=>"35", "Ben"=>"37");

o Access: $age['Peter']

 Multidimensional Arrays: Arrays containing one or more arrays (Matrix).

2. Functions:

Blocks of code that can be reused.

 Built-in Functions: PHP has 1000+ functions (e.g., date(), strlen()).

 User Defined Functions:

o Syntax: function funcName($param) { ... return $value; }

o They improve code modularity and readability.

Q16. Explain PHP form handling. (PYQ – VERY HIGH)

Answer:

Definition:

PHP is the standard backend language for processing HTML forms. It uses Superglobals to
collect data sent by the client.

Methods:

1. $_GET:

o Data is sent in the URL (Visible to everyone).

o Usage: Search bars, bookmarkable pages.

o Limit: ~2000 characters.

o Security: Low.

2. $_POST:

o Data is sent in the HTTP Body (Invisible in URL).

o Usage: Login forms, file uploads, sensitive data.

o Limit: No specific size limit.


o Security: Higher than GET.

Example:

 HTML: <form action="[Link]" method="POST">

 PHP: $username = $_POST['username'];

Conclusion: PHP form handling bridges the gap between static user input and dynamic
server processing.
Unit-III: Servlets & JSP

Q1. What is a Servlet? Explain its role in web applications. (AKASH PYQ – VERY HIGH)

Answer:

Definition:

A Servlet is a Java programming language class used to extend the capabilities of servers
that host applications accessed by means of a request-response programming model.
Although servlets can respond to any type of request, they are commonly used to extend
the applications hosted by web servers (handling HTTP requests).

Key Characteristics:

 Server-Side: Runs inside a Servlet Container (like Apache Tomcat).

 Persistent: Remains in memory between requests (unlike CGI).

 Platform Independent: Written in Java, follows "Write Once, Run Anywhere."

Role of Servlets in Web Applications:

1. Dynamic Content Generation: Unlike static HTML files, servlets can generate unique
content based on user input (e.g., displaying a user's profile name).

2. Request Handling: It reads the explicit data sent by the clients (HTML form data) and
implicit HTTP request data (cookies, media types).

3. Business Logic Processing: It acts as the "Controller" in MVC architecture, processing


logic and talking to the database.

4. Session Management: It maintains state across multiple stateless HTTP requests


using HttpSession or Cookies.

5. Security: It handles authentication and authorization before allowing access to


resources.

Conclusion: Servlets are the foundational building block of Java EE web development; even
JSP and JSF are built on top of the Servlet API.

Q2. Explain the advantages of Servlets over CGI. (AKASH PYQ – DIRECT)

Answer:

Common Gateway Interface (CGI) was the older technology where every client request
spawned a new process on the OS. Servlets improved upon this significantly.
Feature CGI (Common Gateway Interface) Servlets

Thread-based: Creates a light-weight


Execution Process-based: Creates a new heavy-
thread for every request within a
Model weight process for every request.
single process.

Slow: High overhead due to frequent


Fast: Low overhead; threads share
Performance context switching and process
memory and resources.
creation.

Low: Cannot handle high concurrent High: Can handle thousands of


Scalability
traffic (server crashes). concurrent requests efficiently.

Servlets remain in memory (stay


CGI scripts are loaded and unloaded
Persistence resident) to handle subsequent
from memory after every request.
requests.

Dependent on the OS and server


Platform Independent (Java-based).
implementation.

Session Mgmt Difficult to implement. Native support via HttpSession.

Conclusion: Servlets replaced CGI because they are significantly more efficient, scalable, and
secure.

Q3. Explain Servlet Architecture and Components. (AKASH PYQ – VERY HIGH)

Answer:

The Servlet Architecture relies on a Web Container (also called a Servlet Container or Servlet
Engine) to manage the execution of servlets.

Key Components:

1. Client (Browser): Sends HTTP requests to the web server.

2. Web Server: Handles static content (HTML, Images) and passes dynamic requests to
the Servlet Container.

3. Servlet Container (e.g., Tomcat, Jetty):

o It contains and manages the servlets.

o Network Services: Encodes/Decodes requests and responses.

o Lifecycle Management: Loads, initializes, and destroys servlets.

o Multithreading: Creates a new thread for every request.


4. The Servlet: The Java code written by the developer to handle the business logic.

5. Deployment Descriptor ([Link]): Maps URLs to specific servlets (optional in


modern Servlet versions using annotations).

Working Flow:

Request $\rightarrow$ Web Server $\rightarrow$ Container $\rightarrow$ service() thread


$\rightarrow$ Response.

Q4. Explain the Servlet Life Cycle with diagram description. (AKASH PYQ – VERY HIGH)

Answer:

The Servlet Life Cycle is controlled entirely by the Servlet Container. It consists of four main
phases.

Phases:

1. Loading and Instantiation:

o The container loads the Servlet class into memory.

o It creates an instance of the servlet using the default constructor.

2. Initialization (init()):

o Called Only Once.

o The container calls public void init(ServletConfig config).

o Used for one-time setup (e.g., database connection opening, reading


parameters).

3. Request Handling (service()):

o Called for Every Request.

o The container calls public void service(ServletRequest req, ServletResponse


res).

o It dispatches the request to doGet(), doPost(), etc., based on the HTTP


method.

o Each request runs in a separate thread.

4. Destruction (destroy()):

o Called Only Once.

o Called before the servlet is removed from memory (e.g., server shutdown).
o Used for cleanup (closing DB connections, saving state).

Conclusion: The lifecycle ensures resource efficiency by initializing heavy resources only
once.

Q5. Explain HTTPServlet class and its methods. (AKASH PYQ)

Answer:

Definition:

HttpServlet is an abstract class that extends GenericServlet. It provides specific support for
the HTTP protocol. Web developers typically extend this class to build web applications.

Hierarchy:

Servlet (Interface) $\rightarrow$ GenericServlet (Abstract Class) $\rightarrow$ HttpServlet


(Abstract Class).

Important Methods:

1. service(HttpServletRequest, HttpServletResponse): The main entry point. It checks


the HTTP request type (GET, POST, etc.) and calls the corresponding doXxx method.

2. doGet(): Override this to handle HTTP GET requests (fetching data).

3. doPost(): Override this to handle HTTP POST requests (submitting form data).

4. doPut(): Handles HTTP PUT requests (updating resources).

5. doDelete(): Handles HTTP DELETE requests.

Conclusion: By extending HttpServlet, developers focus only on business logic


(doGet/doPost) rather than parsing raw network protocols.

Q6. Explain GET and POST methods in Servlets. (AKASH PYQ – VERY HIGH)

Answer:

GET and POST are the two most common HTTP methods used to send data from a browser
to a server.

Feature GET Method POST Method

Used to retrieve data from the Used to submit/send data to the server
Purpose
server. for processing.

Data Visibility Data is appended to the URL (Query Data is sent in the Request Body.
Feature GET Method POST Method

String). Visible to everyone. Hidden from the user.

Low: Never use for


Security Higher: Suitable for sensitive data.
passwords/sensitive data.

Limited (approx 2KB - 8KB


Data Limit Unlimited: Can send large files/images.
depending on browser).

Bookmarking Can be bookmarked. Cannot be bookmarked.

Non-Idempotent: Multiple requests


Idempotent: Multiple requests have
Idempotency create multiple resources (e.g.,
the same effect (safe).
duplicate orders).

Conclusion: Use GET for reading/searching; Use POST for writing/updating.

Q7. Explain Request and Response objects in Servlets. (AKASH PYQ)

Answer:

When a client sends a request, the Container creates two objects and passes them to the
service() method.

1. HttpServletRequest (The Input):

 Represents the request sent by the browser.

 Key Functions:

o getParameter(String name): Fetches form data (e.g., username).

o getHeader(String name): Reads HTTP headers (User-Agent, Content-Type).

o getSession(): Retrieves the current user session.

o setAttribute() / getAttribute(): Shares data between servlets.

2. HttpServletResponse (The Output):

 Represents the response the server sends back.

 Key Functions:

o getWriter(): Returns a PrintWriter to write HTML content to the browser.

o setContentType(String type): Tells the browser what data is coming (e.g.,


"text/html").
o sendRedirect(String url): Redirects the user to a new page.

o addCookie(Cookie c): Sends a cookie to the client.

Q8. Explain Session Management in Servlets. (AKASH PYQ – VERY HIGH)

Answer:

Definition:

HTTP is a Stateless Protocol (it forgets the user after every request). Session Management is
the technique used to track a user's state across multiple requests (e.g., keeping a user
logged in or maintaining a shopping cart).

Techniques:

1. Cookies: Small text files stored on the client's browser. Sent back to the server with
every request.

2. HttpSession (The Standard Way):

o The server creates a generic object (HttpSession) for the user.

o A unique ID (JSESSIONID) is generated and sent to the client as a cookie.

o The server uses this ID to map requests to the correct session object.

3. URL Rewriting: Appending the session ID to the URL (e.g., url?jsessionid=123). Used
when cookies are disabled.

4. Hidden Form Fields: Storing state in <input type="hidden"> tags within forms.

Conclusion: HttpSession is the most robust and secure method for server-side state
management.

Q9. Explain Cookies and HttpSession with comparison. (AKASH PYQ)

Answer:

Cookies:

 Client-side state management.

 Data is stored as text files on the user's hard drive/browser memory.

 Persistent Cookies: Remain after browser closes (have an expiry).

 Non-Persistent: Deleted when browser closes.

HttpSession:
 Server-side state management.

 Data is stored in the Server's RAM (Heap memory).

 Relies on a "Session ID" cookie to identify the user.

Comparison:

Feature Cookies HttpSession

Storage Location Client (Browser). Server.

Security Low (Can be edited/stolen). High (Data stays on server).

Data Type Only Strings. Any Java Object.

Capacity Limited (4KB per cookie). Unlimited (Depends on server RAM).

Q10. What is JSP? Explain its need and advantages. (AKASH PYQ – VERY HIGH)

Answer:

Definition:

JSP (JavaServer Pages) is a server-side technology that allows developers to create dynamic
web pages. It enables mixing HTML (for layout) with Java code (for logic) using special tags.

Need for JSP:

 Writing HTML inside Servlets (using [Link]("<html>...")) is tedious, error-prone,


and hard to format.

 JSP reverses this: You write HTML normally and inject Java only where needed.

Advantages:

1. Separation of Concerns: Presentation (HTML) is separated from Logic (Java


Beans/Servlets).

2. Ease of Development: Web designers can edit the HTML without knowing advanced
Java.

3. Fast Development: Easier to visualize the page structure compared to Servlets.

4. Reusability: Supports Tag Libraries (JSTL) and Custom Tags.

5. Implicit Objects: Provides built-in objects like request and session without
instantiation.

Conclusion: JSP is essentially a high-level abstraction of Servlets, designed for the "View"
layer.
Q11. Explain JSP Architecture and Life Cycle. (AKASH PYQ – VERY HIGH)

Answer:

JSP Architecture:

A JSP page is translated into a Servlet by the JSP engine (Container) before it is executed. It
does not run as a text file.

Life Cycle Phases:

1. Translation: The Container checks the JSP syntax and generates a Java Servlet file
(.java).

2. Compilation: The Java file is compiled into a class file (.class).

3. Loading & Instantiation: The class is loaded, and an instance is created.

4. Initialization (jspInit()): Similar to servlet init().

5. Request Processing (_jspService()): Handles client requests. This method contains


the code written in the JSP.

6. Destruction (jspDestroy()): Cleanup code.

Conclusion: The Translation and Compilation happen only once (first request), making
subsequent requests very fast.

Q12. Explain JSP Scripting Elements. (AKASH PYQ – VERY HIGH)

Answer:

Scripting elements allow you to insert Java code into the JSP.

1. Scriptlet Tag (<% code %>):

o Used to write valid Java logic (loops, if-else, variable declarations).

o Code placed here goes inside the _jspService() method.

o Example: <% int count = 0; [Link](count); %>

2. Expression Tag (<%= expression %>):

o Used to print values directly to the output stream.

o Does not contain a semicolon (;).

o Example: Current Time: <%= new [Link]() %>


3. Declaration Tag (<%! declaration %>):

o Used to declare methods or instance variables.

o Code here goes outside _jspService(), making variables global to the class.

o Example: <%! int globalCount = 0; %>

Conclusion: While powerful, modern JSP development avoids scripting elements in favor of
JSTL/EL.

Q13. Explain JSP Directives. (AKASH PYQ)

Answer:

Definition:

Directives give instructions to the JSP container on how to translate the page into a servlet.
They do not produce output directly.

 Syntax: <%@ directive attribute="value" %>

Types:

1. Page Directive: Controls page-dependent attributes.

o Imports: <%@ page import="[Link].*" %>

o Error Handling: <%@ page errorPage="[Link]" %>

o Content Type: <%@ page contentType="text/html" %>

2. Include Directive: Statically includes the content of another file at translation time.

o Example: <%@ include file="[Link]" %> (The code is copied and pasted).

3. Taglib Directive: Imports custom tag libraries like JSTL.

o Example: <%@ taglib uri="[Link] prefix="c" %>

Q14. Explain JSP Implicit Objects. (AKASH PYQ – VERY HIGH)

Answer:

Definition:

Implicit objects are Java objects that the JSP Container creates automatically. Developers can
use them directly without creating them (no new keyword needed).

Key Objects (Total 9):


1. request (HttpServletRequest): Reading form data.

2. response (HttpServletResponse): Sending responses/cookies.

3. out (JspWriter): Writing content to browser.

4. session (HttpSession): Tracking user sessions.

5. application (ServletContext): Global data for the whole app.

6. config (ServletConfig): Initialization parameters.

7. pageContext: Access to all scopes/attributes.

8. page: Refers to the current servlet instance (this).

9. exception: Captures errors (available only in error pages).

Conclusion: These objects simplify coding by handling the complexity of object creation.

Q15. Explain JSP Action Tags. (AKASH PYQ)

Answer:

Definition:

Action tags are XML-syntax tags used to perform specific operations at request time
(runtime).

Common Action Tags:

1. <jsp:include>:

o Includes the output of another resource at runtime.

o Different from include directive (which copies code).

o Use: Dynamic headers/footers.

2. <jsp:forward>:

o Forwards the request to another page. The user does not see the URL change.

3. <jsp:useBean>:

o Finds or instantiates a JavaBean class.

o Ex: <jsp:useBean id="user" class="[Link]" />

4. <jsp:setProperty> & <jsp:getProperty>:

o Sets or gets values from the Bean.


Conclusion: Action tags encourage component-based development and reduce Java code in
JSP.

Q16. Explain MVC Architecture using Servlets and JSP. (AKASH PYQ – VERY HIGH)

Answer:

Model-View-Controller (MVC) is a design pattern used to decouple the user interface


(View), data (Model), and application logic (Controller).

Components:

1. Model (JavaBeans/POJO):

o Represents the data and business logic (e.g., User class, Database logic).

o It has no knowledge of the UI.

2. View (JSP):

o Represents the presentation layer.

o Displays the data provided by the Model.

o Should not contain business logic.

3. Controller (Servlet):

o The entry point. Receives requests.

o Interacts with the Model to process data.

o Selects the View (JSP) to display the result.

Workflow:

Browser Request $\rightarrow$ Servlet (Controller) $\rightarrow$ Updates Model $\


rightarrow$ Forwards to JSP (View) $\rightarrow$ Response.

Q17. Compare Servlets and JSP. (AKASH PYQ – DIRECT)

Answer:

Feature Servlets JSP (JavaServer Pages)

Java code with HTML embedded


Nature HTML code with Java embedded inside.
inside.

Ease of Hard to write and maintain HTML Easy to write and maintain layout.
Feature Servlets JSP (JavaServer Pages)

Coding (lots of [Link]).

Role in MVC Acts as the Controller. Acts as the View.

Compiled into .class by developer Auto-compiled by the server on the first


Compilation
before deployment. request.

First request is slow (translation


Performance Slightly faster (pre-compiled).
overhead); subsequent are fast.

Capability Strong in logic processing. Strong in presentation.

Q18. Explain JDBC usage in Servlets/JSP. (AKASH PYQ)

Answer:

Definition:

JDBC (Java Database Connectivity) is an API that enables Java applications (Servlets/JSP) to
interact with relational databases.

Steps to use JDBC:

1. Load Driver: [Link]("[Link]");

2. Connection: Connection con = [Link](url, user, pass);

3. Statement: Create Statement or PreparedStatement.

4. Execute: Run SQL (executeQuery for SELECT, executeUpdate for INSERT/UPDATE).

5. Result: Process ResultSet.

6. Close: Close connection to free resources.

Best Practice: In Servlets, always use a Connection Pool (DataSource) instead of raw
DriverManager for better performance.

Q19. Explain Filters and Listeners in Servlets. (AKASH PYQ)

Answer:

1. Filters:

 Objects that intercept requests before they reach the servlet or responses before
they reach the client.
 Use Cases: Authentication checks, Logging, Data compression, Encryption.

 Method: doFilter().

2. Listeners:

 Objects that "listen" for specific events in the servlet lifecycle.

 Types:

o ServletContextListener: Runs when server starts/stops.

o HttpSessionListener: Runs when a session is created/destroyed.

 Use Cases: Counting active users, initializing database connection pools.

Conclusion: Filters change the request; Listeners react to lifecycle events.

Q20. Explain Security in Servlets and JSP. (AKASH PYQ)

Answer:

Web application security is crucial to protect data and resources.

Mechanisms:

1. Authentication: Verifying user identity.

o BASIC: Browser popup login.

o FORM: Custom HTML login page (Most common).

2. Authorization: Verifying if the authenticated user has permission (Roles) to access a


resource.

o Configured in [Link] using <security-constraint>.

3. Data Privacy: Using SSL/TLS (HTTPS) to encrypt data in transit.

4. Programmatic Security: Using [Link]("admin") inside the Servlet code.

5. Input Validation: Sanitizing inputs to prevent SQL Injection and XSS (Cross-Site
Scripting).
Unit-IV: AJAX, Web Services & SOA

Q1. What is AJAX? Explain its need and advantages. (AKASH PYQ – VERY HIGH)

Answer:

Definition:

AJAX (Asynchronous JavaScript and XML) is not a single technology, but a suite of web
development techniques used to create asynchronous web applications. It allows web pages
to be updated asynchronously by exchanging small amounts of data with the server behind
the scenes. This means that it is possible to update parts of a web page, without reloading
the whole page.

Need for AJAX:

In the traditional web model (Classic Web Application):

1. Every user action (like clicking a button) sent an HTTP request to the server.

2. The server processed it and returned a completely new HTML page.

3. The browser had to reload and re-render everything (header, footer, sidebar) even if
only one text field changed.

4. Problem: This "Click-Wait-Refresh" cycle caused high bandwidth consumption, server


load, and a jerky user experience.

Advantages of AJAX:

1. Partial Page Updates: Only the specific part of the DOM that needs new data is
updated.

2. Asynchronous Processing: The user can continue interacting with the page while the
data is being fetched in the background (Non-blocking).

3. Reduced Server Traffic: Instead of sending full HTML pages, the server sends only
small data chunks (JSON/XML).

4. Improved User Experience: The application feels faster and more responsive, similar
to a desktop application.

5. Separation of Data and Format: The server provides data (JSON), and the client
(browser) handles the formatting/HTML generation.

Q2. Explain the working of AJAX with architecture. (AKASH PYQ – VERY HIGH)

Answer:

AJAX Architecture Components:


The architecture relies on an "AJAX Engine" (written in JavaScript) that sits between the User
and the Server.

1. HTML/CSS: For presentation.

2. DOM (Document Object Model): For dynamic display and interaction.

3. XMLHttpRequest Object (XHR): For asynchronous communication with the server.

4. XML/JSON: As the format for data transfer.

5. JavaScript: To bind everything together.

Working Flow:

1. Event Occurrence: An event occurs in a web page (e.g., the user clicks a "Load More"
button).

2. XHR Creation: JavaScript creates an XMLHttpRequest object.

3. Request Sending: The XHR object sends a request to the web server asynchronously.

4. Server Processing: The server processes the request, interacts with the database if
needed, and prepares a response (usually JSON or XML).

5. Response Return: The server sends the data back to the web browser.

6. Callback Execution: A JavaScript callback function is triggered by the


onreadystatechange event.

7. DOM Update: JavaScript parses the response and updates the HTML DOM to display
the new data without a reload.

Q3. Explain XMLHttpRequest object in detail. (AKASH PYQ)

Answer:

Definition:

The XMLHttpRequest (XHR) object is the keystone of AJAX. It provides the API for client-side
scripting languages (like JavaScript) to transfer data between a client and a server via HTTP.

Key Methods:

1. open(method, url, async): Specifies the type of request.

o method: GET or POST.

o url: The server-side script location.

o async: true (asynchronous) or false (synchronous).


2. send(string): Sends the request to the server.

3. setRequestHeader(header, value): Adds HTTP headers (essential for POST requests).

Key Properties:

1. readyState: Holds the status of the XMLHttpRequest.

o 0: UNSENT

o 1: OPENED

o 2: HEADERS_RECEIVED

o 3: LOADING

o 4: DONE (The response is ready).

2. status: Returns the status-number of a request (e.g., 200 for "OK", 404 for "Not
Found").

3. responseText: Returns the response data as a string.

4. responseXML: Returns the response data as XML data.

5. onreadystatechange: An event handler that is called whenever the readyState


attribute changes.

Q4. Explain synchronous and asynchronous requests in AJAX. (AKASH PYQ)

Answer:

The async parameter in the open() method determines the mode of operation.

1. Synchronous Request (async = false):

 Mechanism: The JavaScript code pauses (blocks) at the send() statement and waits
until the server sends back the complete response.

 Impact: The browser freezes (UI becomes unresponsive). The user cannot click or
scroll until the data arrives.

 Usage: Rarely used today; deprecated in modern web development because it ruins
the User Experience.

2. Asynchronous Request (async = true):

 Mechanism: The JavaScript sends the request and immediately continues executing
the next lines of code without waiting.
 Handling: When the server eventually responds, an event (onreadystatechange)
fires, triggering a callback function to handle the data.

 Impact: The UI remains responsive. This is the fundamental principle of AJAX.

Q5. Explain AJAX response handling techniques. (AKASH PYQ)

Answer:

Once the XMLHttpRequest object receives a response (readyState=4, status=200), the data
can be handled in three main formats:

1. Handling Text Response (responseText):

 Used when the server returns a simple string or HTML fragment.

 Example: [Link]("div1").innerHTML = [Link];

2. Handling XML Response (responseXML):

 Used when the server returns structured XML data.

 The response is treated as an XML DOM object. You must use DOM methods like
getElementsByTagName() to extract data.

 Drawback: Parsing XML is verbose and slower in JavaScript.

3. Handling JSON Response:

 Most Popular. The server returns a JSON string.

 JavaScript parses this string into a native JavaScript Object using [Link]().

 Example:

JavaScript

var myObj = [Link]([Link]);

[Link]("demo").innerHTML = [Link];

Q6. What is JSON? Explain its features and advantages. (AKASH PYQ – VERY HIGH)

Answer:

Definition:

JSON (JavaScript Object Notation) is a lightweight text-based format for storing and
transporting data. It is often used when data is sent from a server to a web page. It is
derived from JavaScript object syntax but is language-independent.
Syntax Rules:

 Data is in name/value pairs ("name": "John").

 Data is separated by commas.

 Curly braces {} hold objects.

 Square brackets [] hold arrays.

Features:

1. Lightweight: Smaller file size compared to XML because it lacks closing tags.

2. Language Independent: Parsers exist for C, Python, Java, PHP, etc.

3. Self-describing: easy for humans to read and write.

Advantages over XML:

1. Faster Parsing: JSON is parsed by a standard JavaScript function [Link](), which


is much faster than an XML parser.

2. Data Structure: JSON maps directly to data structures (Objects/Arrays), whereas XML
is a tree structure that requires traversal.

3. Bandwidth: Reduces data transfer size due to compact syntax.

Q7. Explain Web Services and their characteristics. (AKASH PYQ – VERY HIGH)

Answer:

Definition:

A Web Service is a standardized way for two different applications to talk to each other over
a network, regardless of the operating system or programming language they are running
on. It is "Machine-to-Machine" communication using standard web protocols (HTTP).

Characteristics:

1. Interoperability: Allows a Java application on Linux to communicate with a .NET


application on Windows.

2. Standardized Protocols: Uses open standards like XML, JSON, HTTP, SOAP, and WSDL.

3. Loose Coupling: The client and server are independent. A change in the server's
internal logic doesn't necessarily break the client.

4. Stateless: Each request is treated as an independent transaction (mostly in REST).


5. Discoverable: Services can be found using directories like UDDI (though less common
now).

Q8. Explain SOAP-based Web Services. (AKASH PYQ)

Answer:

Definition:

SOAP (Simple Object Access Protocol) is a strict, XML-based protocol for exchanging
information in the implementation of web services. It defines exactly how the message
should look.

SOAP Message Structure:

A SOAP message is an ordinary XML document containing:

1. Envelope: The root element that defines the XML document as a SOAP message.

2. Header (Optional): Contains meta-information like authentication credentials or


transaction IDs.

3. Body: Contains the actual request or response information (the payload).

4. Fault (Optional): Used for holding errors and status information.

Features:

 WS-Security: Has built-in standards for enterprise-level security (SSL + WS-Security).

 ACID Compliance: Supports reliable transactions (Atomicity, Consistency, Isolation,


Durability).

 Protocol Independent: Can technically work over SMTP or TCP, not just HTTP.

Q9. Explain RESTful Web Services. (AKASH PYQ – VERY HIGH)

Answer:

Definition:

REST (Representational State Transfer) is not a protocol but an Architectural Style. Web
services that follow REST guidelines are called RESTful. It treats data as Resources accessed
via URIs.

Key Principles of REST:

1. Resource-Based: Everything is a resource identified by a Unique URI (e.g.,


[Link]
2. HTTP Methods: It uses standard HTTP verbs to perform CRUD operations:

o GET: Retrieve a resource (Read).

o POST: Create a new resource.

o PUT: Update an existing resource.

o DELETE: Remove a resource.

3. Stateless: The server does not store any client context between requests.

4. Representation: Resources can be represented in various formats (JSON, XML,


HTML), but JSON is the most common.

Advantages:

 Scalable and high performance.

 Cacheable responses.

 Easier to implement than SOAP.

Q10. Differentiate between SOAP and REST. (AKASH PYQ – DIRECT)

Answer:

Feature SOAP (Simple Object Access Protocol) REST (Representational State Transfer)

It is an Architectural Style (set of


Nature It is a Protocol with strict standards.
guidelines).

Data Format Uses XML only. Supports JSON, XML, HTML, Text, etc.

High: XML is verbose and requires a


Bandwidth Low: JSON is lightweight.
heavy Envelope.

High (WS-Security). Good for Relies on HTTPS (SSL/TLS). Good for


Security
banking/enterprise. web/mobile apps.

Caching Difficult to cache. Easy to cache (uses HTTP caching).

Complex to implement; requires tools Simple to implement; uses standard


Complexity
to parse WSDL. URIs.

Q11. Explain Service-Oriented Architecture (SOA). (AKASH PYQ – VERY HIGH)

Answer:
Definition:

SOA (Service-Oriented Architecture) is an architectural design pattern where application


components provide services to other components via a communications protocol, typically
over a network.

Core Concept:

Instead of building a giant "Monolithic" application, you break the software into smaller,
distinct functional units called Services (e.g., Payment Service, User Service, Shipping
Service). These services communicate via an Enterprise Service Bus (ESB).

Key Principles:

1. Reusability: A service (like "Check Credit Score") can be reused by the Loan
Department app and the Credit Card app.

2. Loose Coupling: Services are independent. Changes in one do not break others.

3. Interoperability: Services written in Java can talk to services written in Python.

4. Abstraction: The internal logic is hidden; only the interface is exposed.

Conclusion: SOA enables businesses to respond faster to changing market needs by


reassembling existing services.

Q12. Explain WSDL and its role in Web Services. (AKASH PYQ)

Answer:

Definition:

WSDL (Web Services Description Language) is an XML-based language used to describe the
functionality offered by a SOAP web service.

Role (The Contract):

It acts as a Contract between the Service Provider and the Service Consumer. It tells the
client exactly how to talk to the service.

WSDL Document Structure:

1. <types>: Defines the data types used (usually XML Schema).

2. <message>: Defines the data elements for each operation (Request/Response).

3. <portType>: Describes the operations (functions) that can be performed.

4. <binding>: Defines the protocol and data format (e.g., SOAP over HTTP).

5. <service>: Defines the network address (URL) where the service is located.
Q13. Explain UDDI. (AKASH PYQ)

Answer:

Definition:

UDDI (Universal Description, Discovery, and Integration) is an XML-based standard for


describing, publishing, and finding web services. It acts like a Yellow Pages directory for web
services.

Components:

1. White Pages: Contact information (Name, Address, Phone) of the company providing
the service.

2. Yellow Pages: Categorization of the service (e.g., "Credit Card Processing", "Weather
Service") based on standard taxonomies.

3. Green Pages: Technical details (WSDL location) on how to invoke the service.

Process:

 Service Provider registers their service in UDDI.

 Service Consumer queries UDDI to find a service.

 UDDI points the Consumer to the WSDL file.

Q14. Explain security issues in AJAX applications. (AKASH PYQ)

Answer:

AJAX increases the attack surface of a web application because logic is moved to the client
side.

Common Issues:

1. Cross-Site Scripting (XSS): Attackers inject malicious scripts into web pages. Since
AJAX manipulates the DOM, XSS can steal session cookies or redirect users.

2. Cross-Site Request Forgery (CSRF): An attacker tricks a user into executing unwanted
actions on a web application where they are authenticated.

3. SQL Injection: If AJAX parameters are sent directly to a database query without
validation, attackers can manipulate the database.

4. Data Exposure: Since AJAX source code (JavaScript) is visible to the user ("View
Source"), hardcoded API keys or sensitive logic can be stolen.
Solutions:

 Validate all input on the server side.

 Use Anti-CSRF tokens.

 Never trust data coming from the client.

Q15. Explain AJAX vs traditional web applications. (AKASH PYQ)

Answer:

Aspect Traditional Web Application AJAX Web Application

Communication Synchronous (Blocking). Asynchronous (Non-blocking).

User waits for the page to reload Continuous interaction; no wait


User Interaction
after every action. times.

Data Transfer Sends complete HTML page (Heavy). Sends only data (JSON/XML) (Light).

Reduced (Server sends data; Client


Server Load High (Server renders HTML).
renders HTML).

Responsiveness Slower response. Faster, desktop-like feel.

Example Old static websites. Google Maps, Gmail, Facebook Feed.

Q16. Explain advantages and limitations of AJAX. (AKASH PYQ)

Answer:

Advantages:

1. Responsiveness: No page reloads makes the app feel instant.

2. Bandwidth Efficiency: Only data is transferred, saving network usage.

3. Asynchronous Calls: The UI is not blocked during data fetch.

Limitations:

1. SEO Issues: Search engine crawlers have difficulty indexing dynamic content loaded
via JavaScript (though modern crawlers are getting better).

2. Browser History: In pure AJAX, the "Back" button might not work as expected
because the URL doesn't change (Requires HTML5 History API to fix).

3. Security: Increased vulnerability to XSS and code exposure.


4. JavaScript Dependency: If a user disables JavaScript, the application breaks
completely.

Q17. Explain integration of AJAX with Web Services. (AKASH PYQ)

Answer:

This is the foundation of modern SPA (Single Page Applications).

Integration Flow:

1. Front-End: The browser uses AJAX (XMLHttpRequest or Fetch API) to make a


request.

2. Communication: The request is sent to a RESTful Web Service endpoint (e.g., GET
/api/weather).

3. Processing: The Web Service (Backend) processes the logic and queries the database.

4. Response: The Web Service returns data in JSON format.

5. Rendering: The AJAX callback receives the JSON and uses JavaScript to update the UI.

Benefit: The backend becomes a pure "Data Provider" (API), allowing the same web service
to support a Web App, a Mobile App, and 3rd party integrations.

Q18. Explain real-life applications of AJAX. (AKASH PYQ)

Answer:

1. Google Autocomplete: As you type in the search bar, AJAX fetches suggestions
without reloading the page.

2. Google Maps: You can drag the map to see new areas. AJAX fetches the new image
tiles in the background seamlessly.

3. Social Media Feeds (Facebook/Instagram): "Infinite Scroll" uses AJAX to load more
posts as you scroll down.

4. Shopping Carts: Adding an item to the cart updates the cart counter instantly
without refreshing the page.

5. Form Validation: Checking if a "Username is taken" while the user is still typing.

Q19. Explain API and Web API. (AKASH PYQ)

Answer:
API (Application Programming Interface):

 A set of rules and definitions that allows one software program to talk to another.

 Example: A Java program using the JDBC API to talk to a database.

Web API:

 A specific type of API that is accessed over the Web (HTTP).

 It exposes endpoints (URLs) that developers can use to interact with a service.

 Example: The Twitter API allows developers to fetch tweets using HTTP GET requests.

 All Web Services are APIs, but not all APIs are Web Services.

Q20. Explain future trends in Web Technologies. (AKASH PYQ)

Answer:

1. Progressive Web Apps (PWA): Web apps that behave like mobile apps (offline
support, push notifications) using Service Workers.

2. Serverless Computing (AWS Lambda): Developers write code without managing


servers; the cloud provider handles execution.

3. GraphQL: A query language for APIs that allows clients to ask for exactly the data
they need, solving the over-fetching problem of REST.

4. WebAssembly (Wasm): Allows running high-performance languages like C++ and


Rust in the browser alongside JavaScript.

5. AI-Driven Web Apps: Integration of Chatbots and Personalization engines directly


into web interfaces.

You might also like