Writing Java scriptlets inside JSPs is bad practice. In this module, we will explore JSTL core tags, SQL tag updates, and Expression Language scopes.

6.1. JSTL Core Tag Controls & XSS Shielding

Definition: JSTL tags provide programming control structures inside JSP layouts, removing the need for raw Java scriptlets.

Core Working Principles:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<p>Name: <c:out value="${param.name}" default="Guest" /></p>
<c:forEach var="item" items="${itemsList}">
    <p>Item: ${item}</p>
</c:forEach>
5-Marks Exam Scoring Points
  • JSTL Core tags are imported using the namespace directive.
  • c:out tag automatically escapes HTML characters, preventing XSS attacks.
  • c:forEach loop provides index status variables.

6.2. EL Scope Resolution Search Hierarchy

Definition: Expression Language (EL) provides a simple syntax (${expression}) to access variables. The search hierarchy defines the order in which scopes are checked.

Core Working Principles:

5-Marks Exam Scoring Points
  • Access variables using the syntax: ${attributeName}.
  • Searches web scopes sequentially: Page → Request → Session → Application.
  • Returns empty strings on null values, preventing page errors.