The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > javax.servlet.jsp.jstl.core  [6 examples]

e1065. 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 e1064 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.

 Related Examples
e1064. Using the Java Standard Tag Library (JSTL) in a JSP Page
e1066. Getting a Request Parameter Using JSTL in a JSP Page
e1067. Saving Data Using JSTL in a JSP Page
e1068. Saving and Emitting HTML Fragments Using JSTL in a JSP Page
e1069. Conditionally Generating Output Using JSTL in a JSP Page


© 2002 Addison-Wesley.