JSTL is not part of the JSP specification. To use it we need to copy two jar files in the WEB-INF/lib directory of our web application.
I originally wrote this post while developing for Tomcat 7, if you are doing the same, you should find these two files under its home directory, in the webapps\examples\WEB-INF\lib folder, named jstl.jar and standard.jar.
Once you have these two jar available to your web application, you have to make them visible in some way your JSP page, sort of importing a class, if you see what I mean. In JSP you do that using the taglib directive, same mechanism we have seen when we talked about Tag Library Descriptor:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>Pay attention to the uri: in this case I used the path for JSTL version 1.1, since this was the version I have at hand of them; I haven't used JSTL 1.2 yet, but it should use the same uri (but a different jar). In case you use JSTL 1.0 the right path is "http://java.sun.com/jstl/core".
I showed the uri for the "core" tags, the other available tags are grouped in "xml" (expected prefix is "x"), "fmt" ("fmt"), "sql" ("sql"), and "functions" ("fn"). The "functions" are not available on JSTL 1.0.
No comments:
Post a Comment