Notes
JSP Best Practices Review
Ideal JSP Structure
- JSP files should contain presentation logic only (markup syntax/tags)
- Ideal JSPs do NOT have any Java code (no scriptlets or expressions)
Methods to Reduce Scriptlets in JSP:
- JSP Standard Actions
- Java Beans
- JSP EL (Expression Language)
- JSTL Tags
- Custom Tags
Java Beans Quick Review
Bean Structure
Java Bean = Fields + Constructor + Getter/Setter + Business Logic Methods
Bean Scopes (Lowest to Highest):
- Page Scope (default) → PageContext → Current page only
- Request Scope → HttpServletRequest → All pages where request is forwarded/included
- Session Scope → HttpSession → All pages for current user
- Application Scope (highest) → ServletContext → All pages for all users
Bean Usage Pattern: