Webtechmini
Webtechmini
4 5 6
Used for decision-making in programs. console.log(today.getFullYear()); // 2025 The Servlet Container provides:
A. if-else Statement console.log(today.getMonth() + 1); // 3 (Month is 0-based) Lifecycle Management – Controls the servlet’s execution (initialization,
let num = 10; console.log(today.getDate()); // 21 execution, and destruction).
if (num > 0) { Request Handling – Manages client HTTP requests and responses.
console.log("Positive number"); 7. String Object Concurrency Management – Allows multiple users to access servlets
} else { Strings are sequences of characters. simultaneously.
console.log("Negative number"); let str = "Hello, World!"; Session Management – Tracks user sessions using cookies and session
} console.log(str.length); // 13 IDs.
B. switch Statement console.log(str.toUpperCase()); // "HELLO, WORLD!" Role of Servlets in Web Applications
let fruit = "apple"; console.log(str.toLowerCase()); // "hello, world!" Servlets act as the middleware between the client (browser) and the
switch (fruit) { console.log(str.indexOf("World")); // 7 server. Their key responsibilities include:
case "apple": console.log(str.replace("World", "JS")); // "Hello, JS!" Handling client HTTP requests (GET, POST, etc.).
console.log("Apple selected."); Generating dynamic HTML content (unlike static HTML pages).
break; Conclusion Connecting with databases and APIs to fetch/store data.
case "banana": JavaScript provides various data types, variables, and operators for Managing user sessions for authentication and personalization.
console.log("Banana selected."); computation. Processing form submissions from web pages.
break; Java Servlet – Detailed Theoretical Explanation
default: Introduction to Java Servlets 2. HTML Support in Servlets
console.log("Unknown fruit."); A Java Servlet is a server-side Java program that extends the Servlets are capable of dynamically generating HTML content and
} capabilities of web servers by handling client requests, processing sending it as a response to the client. They use the
them, and generating dynamic web responses. Servlets are an integral HttpServletResponse class to write HTML code.
5. Array Object part of Java’s Java EE (Enterprise Edition) platform and work with HTTP Example of HTML Response in Servlet
An array stores multiple values in an ordered list. protocols in a web environment. import java.io.*;
let fruits = ["Apple", "Banana", "Mango"]; import javax.servlet.*;
console.log(fruits[0]); // Apple 1. Servlet Environment and Role import javax.servlet.http.*;
fruits.push("Orange"); // Add element Servlet Environment
fruits.pop(); // Remove last element A Java Servlet operates within a Servlet Container (also known as a public class HelloServlet extends HttpServlet {
console.log(fruits.length); // 3 Web Container), which is part of a web server or application server. public void doGet(HttpServletRequest request, HttpServletResponse
Popular servlet containers include: response) throws ServletException, IOException {
6. Date Object Apache Tomcat response.setContentType("text/html"); // Set response type
The Date object is used to handle date and time. GlassFish PrintWriter out = response.getWriter(); // Get writer object
let today = new Date(); Jetty out.println("<html><body>");
console.log(today.toDateString()); // "Fri Mar 21 2025" JBoss/WildFly out.println("<h1>Welcome to Java Servlet</h1>");
7 8 9
13 14 15
<style> Unlike traditional dynamic web pages, active pages execute scripts Client-side execution (no server dependency).
p { color: blue; } directly within the browser or via server communication. Graphical capabilities for interactive UI elements.
</style> Reasons for Active Web Pages: Cross-platform compatibility (runs on any system with Java).
External CSS – Stored in a separate .css file and linked using <link> tag. Live user interaction – Mouse events, keystrokes, animations. Limited access to system resources for security reasons.
p { color: green; } Real-time updates – Weather updates, live scores.
Key Features of CSS: Reduced server load – Some processing is handled on the client side. C. Comparison: Dynamic vs. Active Web Pages
Separation of content and design (better maintainability). Better performance – Avoids frequent full-page reloads. Feature Dynamic Web Pages Active Web Pages
Reusability (single CSS file for multiple pages). Execution Server-side and client-
Enhances performance (reduces HTML complexity). B. Java Applet Life Cycle Mostly client-side
Location side
Responsive Design (supports different screen sizes). A Java Applet is a small Java program that runs inside a web browser Examples PHP, JSP, ASP.NET, AJAX Java Applets, JavaScript
or an applet viewer. It is a client-side technology that enhances web
Interactivity Moderate High (real-time execution)
D. Comparative Study of Different Technologies for Dynamic Page interactivity.
Creation Applet Life Cycle Stages: Relies on server Runs on client-side,
Performance
Initialization (init()) responses reducing load
Technology Description Use Case
Called when the applet is first loaded. More secure (handled on Less secure (executed on
Client-side scripting for Forms, animations, Security
JavaScript Starting (start()) server) client)
interactivity event handling
Asynchronous updates Live search, chat Executed after init(), starts applet execution.
AJAX Running (paint(Graphics g)) Conclusion
without page reload applications
Handles graphical rendering and user interaction. Dynamic Web Pages provide real-time interactivity using DHTML, CSS,
Server-side scripting for Form handling, JavaScript, and server-side scripting.
PHP Stopping (stop())
backend processing authentication DHTML combines HTML, CSS, JavaScript, and DOM to create
Called when the applet is paused or navigated away.
Microsoft’s server-side Destroying (destroy()) interactive content.
ASP.NET Enterprise applications
technology Frees resources before applet termination. CSS plays a crucial role in enhancing the presentation and
JSP (Java Server Java-based web scripting E-commerce, banking Example of Java Applet responsiveness of web pages.
Pages) language apps import java.applet.Applet; Various technologies (JavaScript, PHP, JSP, ASP.NET) enable dynamic
ReactJS / JavaScript frameworks for Single Page Applications import java.awt.Graphics; page creation, each with its own advantages.
Angular UI development (SPAs) Active Web Pages focus on real-time execution on the client-side for
public class MyApplet extends Applet { better interactivity.
2. Active Web Pages public void paint(Graphics g) { Java Applets were traditionally used for graphical and interactive
A. Need for Active Web Pages g.drawString("Hello, Applet!", 50, 50); content but are now largely replaced by modern technologies like
Active web pages involve real-time client-side or server-side } JavaScript, React, and WebAssembly.
execution to provide dynamic user interaction and data processing. } J2EE and XML – Detailed Theoretical Explanation
Key Features of Java Applets: 1. J2EE Overview
16 17 18
J2EE (Java 2 Platform, Enterprise Edition) is a platform for developing Transaction Management – Ensures data consistency. public class RMIExample extends UnicastRemoteObject implements
and deploying enterprise-level applications. It extends Java SE Security – Role-based access control. RMIInterface {
(Standard Edition) with additional capabilities for building web Scalability – Supports distributed systems. public RMIExample() throws RemoteException {}
applications, distributed systems, and enterprise software. Persistence – Seamless database interaction. public String sayHello() { return "Hello from RMI"; }
A. J2EE Web Services Overview }
Web services in J2EE allow applications to communicate over the C. EJB vs. JavaBeans Advantages of RMI:
internet using standard protocols such as SOAP (Simple Object Access EJB (Enterprise Allows distributed computing in Java applications.
Protocol) and REST (Representational State Transfer). Feature JavaBeans Supports object serialization for sending data over the network.
JavaBeans)
Types of J2EE Web Services: Used for enterprise-level Used for simple data
SOAP-based Web Services Scope E. Basics of JNI (Java Native Interface)
applications handling
Uses XML for structured messaging. Runs in an application JNI (Java Native Interface) allows Java programs to interact with
Based on WSDL (Web Services Description Language). Architecture Runs in a local JVM native code written in C or C++.
server
Example: Banking and financial transactions. Why Use JNI?
Inbuilt security
RESTful Web Services Security No security by default To access low-level system resources (hardware, OS).
mechanisms
Uses HTTP methods (GET, POST, PUT, DELETE). To integrate Java with legacy applications written in C/C++.
Data exchanged in JSON or XML format. Transaction Supports distributed To improve performance by using native code for computation-heavy
No transaction support
Example: Social media APIs (Facebook, Twitter). Support transactions tasks.
Technologies Used in J2EE Web Services: Uses JPA for database Requires manual Steps in Using JNI:
Persistence
JAX-RPC (Java API for XML-based Remote Procedure Call) operations database integration Declare native methods in Java
JAX-WS (Java API for XML Web Services) Implement them in C/C++
JAX-RS (Java API for RESTful Web Services) D. Basics of RMI (Remote Method Invocation) Load the native library in Java using System.loadLibrary()
RMI (Remote Method Invocation) allows Java applications to invoke Example of JNI Method Declaration in Java:
B. Basics of Enterprise JavaBeans (EJB) methods on remote objects located on different JVMs. It is useful for public class JNIExample {
Enterprise JavaBeans (EJB) is a server-side component model used in distributed computing. public native void sayHello(); // Native method
J2EE for building scalable, secure, and transactional enterprise Working of RMI: static { System.loadLibrary("NativeLibrary"); } // Load native library
applications. Define a Remote Interface – Specifies methods to be called remotely. }
Types of EJBs: Implement the Remote Interface – Provide the actual implementation.
Session Beans – Handles business logic; can be Stateless or Stateful. Register the Object with RMI Registry – Makes it accessible to clients. 2. XML (Extensible Markup Language)
Entity Beans – Represents database entities (deprecated in favor of Client Calls the Remote Method – Uses RMI stub to invoke methods. XML (Extensible Markup Language) is a markup language used to store
JPA). Example of RMI Server Code: and transport data in a structured and human-readable format.
Message-Driven Beans (MDBs) – Handles asynchronous messaging import java.rmi.*; A. Basics of XML
(JMS). import java.rmi.server.*; Self-descriptive format – Data is stored in a hierarchical structure.
Key Features of EJB:
19 20 21
Platform-independent – Works across different programming <!ELEMENT title (#PCDATA)> HTML (HyperText Markup Language) is the standard language for
languages. <!ELEMENT author (#PCDATA)> creating web pages. It uses elements to structure content using tags
Extensible – Custom tags can be created. ]> enclosed in angle brackets (< >).
Used in – Web services, configuration files, data exchange, etc. Uses of DTD: Basic HTML Structure:
Example of an XML File: Ensures validity of XML documents. <!DOCTYPE html>
<?xml version="1.0" encoding="UTF-8"?> Defines rules for elements and attributes. <html>
<student> <head>
<name>John Doe</name> D. XML Parsers <title>My First Web Page</title>
<age>22</age> An XML Parser processes XML documents and makes the data </head>
<course>B.Tech</course> available to programs. <body>
</student> Types of XML Parsers: <h1>Welcome to HTML</h1>
DOM (Document Object Model) Parser <p>This is a paragraph in HTML.</p>
B. XML Elements and Attributes Loads the entire XML document into memory. </body>
Elements in XML: Allows tree-based manipulation. </html>
The core building blocks of an XML document. Example: Used in complex XML structures like web services. <!DOCTYPE html> → Defines the document type (HTML5).
Represented as opening and closing tags (<tag>content</tag>). SAX (Simple API for XML) Parser <html> → Root element of the HTML document.
Example of XML Elements: Processes XML sequentially (event-driven). <head> → Contains metadata (title, styles, scripts).
<book> Uses less memory, making it suitable for large XML files. <body> → Contains the visible content of the web page.
<title>Web Technology</title> Example: Used in streaming data processing.
<author>John Smith</author> B. Document Body and Different Tags
</book> E. Sequential vs. Tree-Based Parsing Approach The document body (<body>) contains all visible elements on a web
Attributes in XML: Approach Description Example page, such as headings, paragraphs, links, images, and tables.
Store additional metadata within elements. Sequential Reads XML line by line, event- Commonly Used HTML Tags
Defined inside the opening tag. Data streaming Tag Description
(SAX) driven
Example of XML Attributes: Tree-Based Loads entire XML into a tree Complex XML Headings (H1 is the largest, H6 is the
<book title="Web Technology" author="John Smith" /> <h1> to <h6>
(DOM) structure manipulation smallest)
<p> Paragraph
C. Document Type Definition (DTD)
Introduction to HTML and Web Technologies – Detailed Theoretical <a href="URL"> Hyperlink
DTD (Document Type Definition) defines the structure and rules for an
Explanation <img src="image.jpg"
XML document. Image
1. Introduction to HTML alt="Text">
Example of DTD:
A. Fundamentals of HTML Elements <ul> <li> Unordered list (bulleted)
<!DOCTYPE book [
<!ELEMENT book (title, author)> <ol> <li> Ordered list (numbered)
22 23 24
25 26 27
B. Comparison: Microsoft vs. Java Technologies <body>Hello World!</body> Database Tier: A database that stores application data, accessed via
Feature Microsoft (ASP.NET) Java (J2EE) </html> JDBC (Java Database Connectivity).
Platform Windows-based Cross-platform JSP Processing Flow
Ease of More complex but D. Universal Resource Locator (URL) Client sends a request to a JSP page.
Easier for beginners A URL (Uniform Resource Locator) uniquely identifies a web resource. The JSP engine converts the JSP file into a Servlet.
Use powerful
Example URL: The Servlet is compiled and executed.
Suitable for small to large
Scalability Highly scalable https://www.example.com/index.html The Servlet interacts with the database or business logic.
applications
Components of a URL: The response is sent back to the client as an HTML page.
Strong security Protocol → https:// (Secure HTTP)
Security Integrated Windows security
mechanisms Domain Name → www.example.com B. JSP Servers
Path → /index.html (specific file) JSP pages require web servers with JSP support. Popular JSP servers
4. World Wide Web (WWW) and Web Technologies include:
A. Basic Concepts of WWW Conclusion Apache Tomcat (Open-source, widely used).
Invented by Tim Berners-Lee in 1989. HTML provides the foundation for web pages using elements, text, JBoss Application Server.
Uses Hypertext to link documents. links, lists, and tables. WebLogic Server.
Works on HTTP protocol for communication. Dynamic pages use JavaScript, CSS, and databases. GlassFish.
Web servers and clients communicate using HTTP.
B. Web Client and Web Server Microsoft (.NET) and Java (J2EE) offer competing technologies for web 2. JSP Tags
Web Client (Browser) development. JSP supports different types of tags for embedding Java code into
Requests web pages from a server. Understanding the WWW, URL, and HTTP is crucial for web HTML:
Examples: Chrome, Firefox, Edge. application development. Tag Type Syntax Purpose
Web Server Mastering HTML and web technologies is key to building modern and Used to define global settings like
Stores and serves web pages. interactive websites! Directive <%@
importing Java classes (<%@ page
Examples: Apache, Nginx, IIS. Java Server Pages (JSP) – Detailed Theoretical Explanation Tags directive %>
import="java.util.*" %>)
1. JSP (JavaServer Pages) <%!
C. HTTP Protocol and Frame Format JSP is a server-side technology that allows developers to create Declaration Used to declare class-level variables and
Hypertext Transfer Protocol (HTTP) is used for web communication. declaration
dynamic web pages using Java. It extends Servlets by allowing Java Tags methods (<%! int counter = 0; %>)
HTTP Request Format: %>
code to be embedded directly into HTML. Scriptlet <% Java code Used to embed Java code inside HTML
GET /index.html HTTP/1.1 A. JSP Architecture
Host: www.example.com Tags %> (<% int x = 10; %>)
JSP follows a three-tier architecture, which consists of:
HTTP Response Format: <%=
Client Tier: Web browser that requests a JSP page. Expression Evaluates and prints Java expressions
HTTP/1.1 200 OK expression
Middle Tier: JSP engine, which processes JSP requests and generates Tags (<%= x * 5 %>)
Content-Type: text/html %>
dynamic web content.
<html>
28 29 30
31 32
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
out.println(rs.getString("username"));
}
%>
D. Using CallableStatement
Used for stored procedures.