Enabling the JSTL Expression Language in a JSP Page

There are two versions of the JSTL: one that enables the JSTL expression language support and one that doesn't. JSTL expression language support replaces the expression JSP tag with a more convenient syntax. For example, the JSP expression:
<c_rt:if test='<%= request.getParameter("p") != null %>'> <%= request.getParameter("p") %> </c_rt:if>
would be written as
<c:if test="${param.p != null}"> <c:out value="${param.p}" /> </c:if>
with expression language support enabled. The expression language is currently available only in attribute values. Future versions will allow its use in template text. More detailed information about the expression language is available at http://www.jcp.org/aboutJava/communityprocess/first/jsr052/index.html.

As mentioned in Using the Java Standard Tag Library (JSTL) in a JSP Page, there are four tag libraries that make up the JSTL. There are two versions of each of these libraries. That example declares the use of the four tag libraries that do not support the expression language. Here is an example that declares the use of the four tag libraries that do support the expression language:

<%-- Core with EL --%> <%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> <%-- I18N Formatting with EL --%> <%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %> <%-- SQL with EL --%> <%@ taglib uri="/WEB-INF/tld/sql.tld" prefix="sql" %> <%-- XML with EL --%> <%@ taglib uri="/WEB-INF/tld/x.tld" prefix="x" %>
Note that the taglib directives assume the TLD files are located in WEB-INF/tld.

Comments

3 Mar 2010 - 9:25am by Anonymous (not verified)

it is very good

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.