Unit III Block 2: Session Tracking and JSP
Lectures 21-24 - cookies, HttpSession, JSP basics, and JSP tags
Block Overview
This block completes Unit III by covering state management in web applications and the basics of Java Server Pages. Students move from raw servlet handling into view generation and reusable server-side page components.
Course Outcome: CO-3 (K3 - Application)
Lectures Covered: 21-24
Theme: Sessions and JSP programming
Lecture 21: Session Tracking using Cookies
Example
Cautions
- Do not store sensitive data directly in cookies
- Browser settings can block or clear cookies
Lecture 22: Session Tracking with HttpSession
Why HttpSession Matters
- Keeps state on the server instead of exposing data in the browser
- Useful for authentication, carts, dashboards, and user workflow state
Example
Lecture 23: JSP Introduction & Implicit Objects
What JSP Adds
- Embeds server-side logic into page rendering
- Reduces the need to print HTML manually from servlet code
- Works well as the view layer with servlets/controllers
Common Implicit Objects
requestresponsesessionapplicationoutpageContext
Example
Lecture 24: JSP Scripting, Directives, Actions & Custom Tags
Key JSP Constructs
- Directives: configure the page or include resources
- Scriptlets and expressions: embed Java directly in JSP
- Standard actions:
<jsp:include>,<jsp:forward>,<jsp:useBean> - Custom tags: reusable logic and view helpers
Example
Design Advice
- Keep business logic in servlets/services
- Use JSP mainly for rendering output
- Prefer tags and EL over large scriptlets where possible
Key Takeaways
- Cookies and
HttpSessionsolve different state-tracking needs
- JSP is the view-side companion to servlet processing
- Directives and actions support reusable page composition
- This block completes Unit III and prepares the move into Spring
Next Block
Unit IV begins with Spring Core, dependency injection, bean life cycle, and configuration. - Dependency Injection - Spring Beans and application context