CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-eclipse-jetty--apache-jstl

Apache JSTL dependency aggregation module for Eclipse Jetty web applications

Pending
Overview
Eval results
Files

jstl-core.mddocs/

JSTL Core Tags

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.

Tag Library Declaration

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

Capabilities

URL Generation and Manipulation

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>

Parameter Management

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}" />

Exception Handling

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>

Conditional Processing

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>

Variable Assignment

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>

Output with Escaping

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" />

Error Handling

JSTL core tags can throw the following types of exceptions:

  • JspException: General JSP processing errors
  • NumberFormatException: When used with formatting operations
  • IllegalArgumentException: Invalid parameter values
  • ELException: Expression Language evaluation errors

Common error scenarios:

  • Invalid EL expressions in test conditions
  • Null pointer exceptions when accessing undefined variables
  • Type conversion errors in parameter values
  • Invalid scope specifications in variable assignments

Install with Tessl CLI

npx tessl i tessl/maven-org-eclipse-jetty--apache-jstl

docs

index.md

jetty-integration.md

jstl-core.md

jstl-formatting.md

tile.json