Epj
📘 Unit 1: JDBC, JDBC Architecture, MySQL & Maven
1. What is Enterprise Programming?
Enterprise programming refers to developing large-scale, distributed, and multi-tier applications
that businesses and organizations use. These apps include banking systems, CRMs, ERP, etc.
---
2. Why is Java considered the best choice for Enterprise Programming?
Key features:
Platform Independent (Write Once, Run Anywhere)
Rich API and libraries
Strong community support
Scalability and security
Multithreading and garbage collection
Integration with enterprise tools and frameworks (Spring, Hibernate, etc.)
---
3. Editions of Java:
Java SE (Standard Edition) – Core features, desktop applications.
Java EE (Enterprise Edition) – Web, enterprise, and distributed applications (now Jakarta EE).
Java ME (Micro Edition) – Embedded and mobile devices.
---
4. Why was Java EE renamed to Jakarta EE?
Oracle transferred Java EE to the Eclipse Foundation due to licensing restrictions. The
community renamed it Jakarta EE for open governance and faster innovation.
---
5. What is a ResultSet?
A ResultSet object holds the data retrieved from a database after executing a SELECT query. It
acts like a cursor pointing to the current row.
---
6. What is a PreparedStatement?
PreparedStatement is a precompiled SQL statement that improves performance and protects
against SQL injection.
---
7. Differences between PreparedStatement and ResultSet:
PreparedStatement ResultSet
Executes SQL queries Holds query results
Prevents SQL injection Used for navigation in records
Faster with repeated execution Only used for reading
---
8. Difference: Java Project vs Maven Project
Java Project Maven Project
Manual dependency management Uses pom.xml
Flat structure Lifecycle-based
No automatic build process Standard build lifecycle
---
9. Maven Lifecycle & Commands:
Lifecycle Phases: validate → compile → test → package → install → deploy
Advantages:
Dependency management
Consistent project structure
Easy builds
Commands:
mvn compile
mvn test
mvn package
mvn install
---
10. What is pom.xml?
Project Object Model (POM) file in Maven. It stores project info, dependencies, build config.
---
11. Disadvantages of JDBC:
No connection pooling
Tight coupling with SQL
Poor scalability for large apps
No ORM features
---
12. Types of JDBC Drivers:
Type Name Description Advantage
Type 1 JDBC-ODBC Bridge Uses ODBC driver Easy to use
Type 2 Native API Converts JDBC to DB API Fast
Type 3 Network Protocol Middleware-based Flexible
Type 4 Thin Driver Pure Java Best performance, platform independent
---
13. MySQL Queries using PreparedStatement:
// Create DB
CREATE DATABASE mydb;
// Create Table
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(100));
// Java Insert using PreparedStatement
PreparedStatement ps = con.prepareStatement("INSERT INTO users VALUES (?, ?)");
ps.setInt(1, 1);
ps.setString(2, "Alice");
ps.executeUpdate();
---
14. CRUD Programs:
Optional but recommended (Let me know if you want these fully coded in Java.)
---
📗 Unit 2: Servlets & Web Applications
1. What is a Web Application?
A web app is a program accessed via browser using HTTP/HTTPS. It works in 3-tier:
Client (HTML/CSS/JS)
Server (Servlet/JSP)
Database (MySQL)
---
2. What is a Servlet?
Java class that handles HTTP requests and generates responses dynamically. Runs on
server-side.
---
3. Static vs Dynamic Web Pages:
Static Dynamic
HTML only HTML + server logic
Same for all users Personalized per user
No backend logic Uses Servlet, JSP
---
4. Servlet Collaboration:
Sharing data between servlets. Techniques:
RequestDispatcher (forward() and include())
sendRedirect()
Shared objects via ServletContext
---
5. Servlet Lifecycle:
1. init()
2. service()
3. destroy()
---
6. What is a GenericServlet?
Abstract class implementing Servlet. Protocol-independent. Used when protocol like HTTP is
not a concern.
---
7. What is ServletContext?
Used to share data across servlets in a web app.
ServletContext context = getServletContext();
context.setAttribute("company", "TCS");
---
8. What is ServletConfig?
Stores config parameters per servlet (defined in web.xml).
ServletConfig config = getServletConfig();
String param = config.getInitParameter("driver");
---
9. doGet() vs doPost():
doGet() doPost()
Data in URL Data in body
Less secure More secure
Limited data Large data
---
10. Deployment Descriptor:
web.xml file that configures servlets, mappings, init parameters, etc.
---
11. Web App Layers (Zomato Example):
1. Presentation Layer (HTML, JSP)
2. Business Logic (Servlets, Java classes)
3. Data Layer (MySQL)
Example:
User logs in → servlet checks database → returns response to JSP
---
12. Form + CRUD via Servlet:
Create HTML form (login.html)
Send data to Servlet (LoginServlet.java)
Use JDBC to read/write data
---
13. HTTP vs HTTPS:
HTTP HTTPS
Not encrypted Encrypted with SSL
Port 80 Port 443
Less secure Secure communication
---
14. Cookies & Sessions:
Cookie: Small file stored in client browser.
Cookie c = new Cookie("user", "admin");
response.addCookie(c);
Session Handling:
HttpSession session = request.getSession();
session.setAttribute("user", "admin");
---
15. What is Session Management?
Process of tracking user data across requests (login, cart, etc.).
Advantages:
Personalization
Maintains continuity across pages
---
📙 Unit 3: JSP (JavaServer Pages)
1. What is JSP? Uses & Advantages:
JSP is a server-side technology that allows embedding Java into HTML.
Advantages:
Easy to write
Automatically compiled to servlet
Tag-based
---
2. Servlet vs JSP:
Servlet JSP
Java code only HTML with Java
Good for logic Good for UI
Hard to design Easier design
---
3. Scripting Elements in JSP:
Type Syntax Purpose
Scriptlet <% code %> Java code
Declaration <%! code %> Declare variables/methods
Expression <%= expr %> Output to HTML
Example:
<% int a = 10; %>
<%! int square(int x) { return x*x; } %>
<%= square(a) %>
---
4. Directive Elements in JSP:
Page Directive: Defines page info
<%@ page language="java" contentType="text/html" %>
Include Directive: Includes a file at compile time
<%@ include file="header.jsp" %>
Taglib Directive: Declares a tag library (e.g., JSTL)
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
---
Would you like:
Printable PDF versions?
One-liner revision flashcards?
Full CRUD Java code?
Let me know how you'd like to revise!