Setup application to use JavaServer Pages Standard Tag Library(JSTL)

Author posted by Jitendra on Posted on under category Categories JSP and tagged as Tags , with Leave a comment on Setup application to use JavaServer Pages Standard Tag Library(JSTL)

Setup application to use JavaServer Pages Standard Tag Library(JSTL)

To check whether JSTL is supported by your web container or not, run below code in jsp page:

Simple Test for JSTL Support: ${1+1}
<c:out value="${1+1}" />

With taglib url as :

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

Or

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


If jstl is not supported by your application, then it will give error like:

org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)

Or

org.apache.jasper.JasperException: /test_c2_jstl_core_taglib_decl.jsp(11,32) According to TLD or attribute directive in tag file, attribute value does not accept any expressions
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)

To give the jstl support to your applications, download “JSTL API” and “JSTL Implementation” jar files from here and paste it into the lib folder of your web application.

Now run the jsp page again, and you will be able to check output.
JSTL includes a wide variety of tags that fit into discrete functional areas. To reflect this, as well as to give each area its own namespace, JSTL is exposed as multiple tag libraries. The URIs for the libraries are as follows:

  1. Core: http://java.sun.com/jsp/jstl/core
  2. XML: http://java.sun.com/jsp/jstl/xml
  3. Internationalization: http://java.sun.com/jsp/jstl/fmt
  4. SQL: http://java.sun.com/jsp/jstl/sql
  5. Functions: http://java.sun.com/jsp/jstl/functions

Related posts