This article helps you migrate from JSP Standard Tag Library (JSTL 1.2) to Jakarta Standard Tag Library (JSTL 2.0) in terms of updating URIs in taglib directives, which is perhaps one of the major changes in the new version of JSTL.

You now, in JSTL 1.2, URIs in taglib directives starting with http://java.sun.com/jsp/jstl/. Now in JSTL 2.0, the URIs must start with jakarta.tags.core.

 

1. taglib directive for using core tags

With JSTL 1.2, the directive to use core tags is:

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

And in JSTL 2.0, it should be:

<%@ taglib prefix="c" uri="jakarta.tags.core" %>

Got the difference?


2. taglib directive for using format tags

To use format tags in JSTL 1.2, you declare the following taglib URI:

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

Now it should be as follows in JSTL 2.0:

<%@ taglib prefix="fmt" uri="jakarta.tags.fmt" %>


3. taglib directive for using function tags

The following taglib directive is declared for using function tags in JSTL 1.2:

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



When migrated to JSTL 2.0, you should use the following:

<%@ taglib prefix="fn" uri="jakarta.tags.functions" %>


4. taglib directive for using SQL tags

To use SQL tags in JSTL 1.2, the following taglib directive should be declared:

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

And with Jakarta Standard Tag Library, you should use the following:

<%@ taglib prefix="sql" uri="jakarta.tags.sql" %>


5. taglib directive for using XML tags

JSTL XML tags can be used given the following taglib directive declared in a JSP page:

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

If migrated to Jakarta XML tags, use the following declaration:

<%@ taglib prefix="x" uri="jakarta.tags.xml" %>

Hope you find this post helpful in Java web development with JSP and JSTL.

 

Learn more:

 


About the Author:

is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.



Add comment