Keywords: JSTL | JSP | Tomcat | Maven | Java EE | Tag Library
Abstract: This paper provides an in-depth exploration of common JSTL (JSP Standard Tag Library) installation and configuration issues, including URI resolution errors and version compatibility problems. Through detailed analysis of specific error cases, it explains URI changes across different JSTL versions, dependency management strategies, and provides comprehensive configuration guides for various Tomcat versions. The article also covers web.xml configuration requirements, Maven dependency management best practices, and proper JSTL usage in different Java EE server environments.
Problem Background and Error Analysis
In JSP development, JSTL (JSP Standard Tag Library) is widely used, but developers often encounter various errors during installation and configuration. The most common errors include:
org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
These errors typically stem from version mismatches or configuration errors. Let's analyze the root causes in depth.
JSTL Version Evolution and URI Changes
JSTL has evolved through several important versions, each with specific URI formats:
- JSTL 1.0: Uses
http://java.sun.com/jstl/coreURI - JSTL 1.1 and later: URI includes
/jsppath, becominghttp://java.sun.com/jsp/jstl/core - JSTL 3.0: Adopts URN format URI:
jakarta.tags.core
This URI evolution stems from JSTL's integration with JSP specifications. Starting from JSTL 1.1, Expression Language (EL) was integrated into JSP 2.0 specification, enabling EL expressions to be reused in plain JSP pages.
Dependency Management Issues and Solutions
In Maven projects, a common misconfiguration is mixing different versions of JSTL implementations:
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
This configuration mixes Apache's JSTL 1.1 implementation with Oracle's JSTL 1.2 API, causing version conflicts. The correct approach is to choose a single implementation version and ensure API and implementation versions match.
JSTL Configuration in Tomcat Environments
Tomcat 10.1.x Configuration
Tomcat 10.1.x is the second Jakarta EE version, using jakarta.* package names and new URN namespaces. Configure JSTL 3.0:
<dependency>
<groupId>jakarta.servlet.jsp.jstl</groupId>
<artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>jakarta.servlet.jsp.jstl</artifactId>
<version>3.0.1</version>
</dependency>
Corresponding taglib declaration:
<%@ taglib prefix="c" uri="jakarta.tags.core" %>
Tomcat 10.0.x Configuration
Tomcat 10.0.x is the first Jakarta EE version, configure JSTL 2.0:
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>jakarta.servlet.jsp.jstl</artifactId>
<version>2.0.0</version>
</dependency>
Tomcat 9 and Earlier Configuration
For Tomcat 9 and earlier versions, use JSTL 1.2:
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>jakarta.servlet.jsp.jstl</artifactId>
<version>1.2.6</version>
</dependency>
Corresponding taglib declaration:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
JAR File Management for Non-Maven Projects
For projects not using Maven, manually place the appropriate JAR files in the /WEB-INF/lib directory:
- Ensure only necessary JAR files are included
- Remove all duplicate or conflicting JAR files (such as
standard*.jar) - Do not place loose
.tldfiles
Java EE Server Environment Configuration
In full Java EE servers (such as WildFly, Payara, TomEE, GlassFish, etc.), JSTL is already built-in. In this case, simply use the provided scope in Maven:
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>10.0.0</version>
<scope>provided</scope>
</dependency>
web.xml Configuration Requirements
Ensure web.xml declaration conforms to at least Servlet 2.4 specification to prevent EL expressions from failing in JSTL tags. Below are configuration examples for different versions:
Servlet 6.0 (Tomcat 10.1.x)
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd"
version="6.0">
<!-- Configuration content -->
</web-app>
Servlet 5.0 (Tomcat 10.0.x)
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
version="5.0">
<!-- Configuration content -->
</web-app>
Servlet 4.0 (Tomcat 9)
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<!-- Configuration content -->
</web-app>
Common Error Types and Diagnostics
Beyond URI resolution errors, developers may encounter:
- Tag Library Descriptor Not Found: Usually caused by version mismatches or missing JAR files
- NoClassDefFoundError: Missing necessary dependencies in classpath
- ClassCastException: Mixing different versions of JSTL implementations
Best Practices Summary
To ensure proper JSTL functionality, follow these best practices:
- Choose JSTL versions compatible with target runtime environment
- Use single, consistent JSTL implementation
- Properly configure Maven dependencies or manually manage JAR files
- Use correct taglib URI declarations
- Ensure web.xml configuration meets Servlet specification requirements
- Regularly update to stable versions for security and performance improvements
By following these guidelines, developers can avoid common JSTL configuration issues and ensure stable operation of web applications.