Apache JSTL dependency aggregation module for Eclipse Jetty web applications
—
The JSTL Core tag library provides fundamental JSP functionality including conditionals, loops, URL manipulation, variable management, and exception handling. These tags form the foundation of server-side logic in JSP pages.
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>Creates and manipulates URLs with automatic encoding and session handling, supporting both absolute and relative URL generation with parameter addition.
<!-- Basic URL generation -->
<c:url value="/path/to/resource" />
<!-- URL with variable -->
<c:url value="/path/to/resource" var="urlVar" />
<!-- URL with parameters -->
<c:url value="/servlet">
<c:param name="param1" value="value1" />
<c:param name="param2" value="value2" />
</c:url>Usage Example:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!-- Create a URL with parameters -->
<c:url value="/user/profile" var="profileUrl">
<c:param name="userId" value="${currentUser.id}" />
<c:param name="tab" value="settings" />
</c:url>
<!-- Use the generated URL -->
<a href="${profileUrl}">User Profile</a>
<!-- Direct inline usage -->
<form action="<c:url value='/submit'/>">
<!-- form content -->
</form>Adds parameters to parent URL tags with automatic encoding and proper URL formatting.
<c:param name="parameterName" value="parameterValue" />
<c:param name="parameterName" value="${dynamicValue}" />Catches and handles exceptions that occur within the tag body, providing graceful error handling for JSP operations.
<c:catch var="exceptionVariable">
<!-- Code that might throw exceptions -->
</c:catch>Usage Example:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<c:catch var="parseError">
<fmt:parseNumber var="number" value="${userInput}" />
</c:catch>
<c:if test="${parseError != null}">
<div class="error">
Invalid number format: ${parseError.message}
</div>
</c:if>
<c:if test="${parseError == null}">
<div class="success">
Parsed number: ${number}
</div>
</c:if>Evaluates conditions and conditionally includes content based on boolean expressions using EL (Expression Language).
<c:if test="${condition}">
<!-- Content to include if condition is true -->
</c:if>
<c:if test="${condition}" var="resultVariable">
<!-- Content with result stored in variable -->
</c:if>Usage Example:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!-- Simple condition -->
<c:if test="${user.isAdmin}">
<div class="admin-panel">Admin Controls</div>
</c:if>
<!-- Complex condition with operators -->
<c:if test="${user.age >= 18 && user.verified}">
<div class="adult-content">Adult Content Available</div>
</c:if>
<!-- Null checking -->
<c:if test="${sessionScope.cart != null && not empty sessionScope.cart.items}">
<div class="cart-summary">Items in cart: ${fn:length(sessionScope.cart.items)}</div>
</c:if>Sets and manages variables in various JSP scopes (page, request, session, application).
<c:set var="variableName" value="value" />
<c:set var="variableName" value="${expression}" />
<c:set var="variableName" value="value" scope="page|request|session|application" />
<c:set var="variableName">
<!-- Body content as value -->
</c:set>Outputs values with automatic XML/HTML escaping to prevent XSS attacks.
<c:out value="${expression}" />
<c:out value="${expression}" default="defaultValue" />
<c:out value="${expression}" escapeXml="true|false" />JSTL core tags can throw the following types of exceptions:
Common error scenarios:
Install with Tessl CLI
npx tessl i tessl/maven-org-eclipse-jetty--apache-jstl