It look like that you’re using JSTL 1.0 with taglib URIs of 1.1/1.2. You have JSTL in different versions:
- 1.0: exist of two JAR files
jstl.jar
andstandard.jar
. Taglib URI is has no/jsp
in path and library name is suffixed with_rt
likehttp://java.sun.com/jstl/core_rt
. Came along and requires at minimum Servlet 2.3 / JSP 1.2. Is end of life, do not use it nowadays. - 1.1: exist of same JAR files as 1.0. Taglib URI has no suffix and includes
/jsp
in the path likehttp://java.sun.com/jsp/jstl/core
. Came along and requires at minimum Servlet 2.4 / JSP 2.0. - 1.2: exist of one JAR file
jstl-1.2.jar
and has same tagtlib URI as 1.1. Came along with Servlet 2.5 / JSP 2.0 but works at Servlet 2.4 / JSP 2.0 as well.
You can find the exact JSTL version by extracting the JAR file with a zip tool and reading the MANIFEST.MF
file.
The Servlet/JSP version depends on the webcontainer/application server used (even more, it is a Servlet/JSP implementation) and version level is configureable in web.xml
. If you’re using at least Servlet 2.5 / JSP 2.0 implementation such as Tomcat 6.0, then I’d recommend to just pick JSTL 1.2. Installing JSTL shouldn’t be that hard:
-
Place the jstl-1.2.jar file in
Webapp/WEB-INF/lib
. Or when you’re using Maven:<dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency>
-
Declare the taglib in JSP file with the right TLD URI. You can find here the TLD documentation which applies on both JSTL 1.1 and JSTL 1.2. Click the taglib of interest to get the declaration examples.
Ensure that you have no duplicates of older JSTL versions in the classpath (includes JRE/lib
and Appserver/lib
) to avoid collisions. If you have full admin-level control over the appserver, then you could also place the JAR file(s) in Appserver/lib
instead of Webapp/WEB-INF/lib
so that it get applied on all deployed webapps. At least do NOT extract the JAR file(s) and clutter the classpath with its contents (the loose TLD files) and/or declare the taglibs in your webapp’s web.xml
as some poor online tutorials suggests.
The servlet version declaration in web.xml
has also incfluence on functioning of JSTL. Common practice is that you declare it to the highest which your webcontainer/appserver supports. In case of Servlet 3.0, the web.xml
should look like:
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<!-- Config here. -->
</web-app>
Make sure that you don’t have a <!DOCTYPE ...>
in there, otherwise it will run in Servlet 2.3 compatibility modus and then EL expressions will stop working.