13-10 Developing Web Applications, Servlets, and JSPs for Oracle WebLogic Server
flush—Setting this boolean attribute to true buffers the page output and then flushes the buffer before including the resource. Setting flush=false can be
useful when the jsp:include tag is located within another tag on the JSP page and you want the included resource to be processed by the tag.
13.10 JSP Expression Language
The new JSP expression language JSP EL 2.1 is inspired by both ECMAScript and the XPath expression languages. The JSP EL is available in attribute values for standard
and custom actions and within template text. In both cases, the JSP EL is invoked consistently by way of the construct {expr} or {expr}.
The {expr} syntax refers to deferred expressions introduced in JSP EL 2.1. Expressions delimited by {} use deferred evaluation because the expression is not
evaluated until its value is needed by the system, and so can be processed by the underlying mechanism at the appropriate moment within its life cycle. Whereas,
expressions delimited by {} use immediate evaluation because the expression is compiled when the JSP page is compiled and it is executed when the JSP page is
executed. The deferred expression includes deferred ValueExpression and deferred MethodExpression. The {expr} syntax is supported in JSP EL 2.1.
The addition of the JSP EL to the JSP technology better facilitates the writing of scriptlets JSP pages. These pages can use JSP EL expressions but cannot use Java
scriptlets, Java expressions, or Java declaration elements. You can enforce this usage pattern through the scripting-invalid JSP configuration element of the web.xml
deployment descriptor.
For more information on the JSP expression language, see the http:java.sun.comproductsjspdownloadindex.html
.
13.10.1 Expressions and Attribute Values
You can use JSP EL expressions in any attribute that can accept a run-time expression, whether it is a standard action or a custom action. The following are use-cases for
expressions in attribute values:
■
The attribute value contains a single expression construct of either some:tag value={expr} or some:tag value={expr}. In this case, the
expression is evaluated and the result is coerced to the attributes expected type according to the type conversion rules described in section 1.18, Type
Conversion, of
http:java.sun.comproductsjspdownloadindex.html .
■
The attribute value contains one or more expressions separated or surrounded by text of either: some:tag value=some{expr}{expr}text{expr}
or some:tag value=some{expr}{expr}text{expr}. In this case, the expressions are evaluated from left to right, coerced to Strings according to
the type conversion rules described later, and concatenated with any intervening text. The resulting String is then coerced to the attributes expected type according
to the type conversion rules described in section 1.18, Type Conversion, of
http:java.sun.comproductsjspdownloadindex.html .
■
The attribute value contains only text: some:tag value=sometext. In this case, the attributes String value is coerced to the attributes expected type
according to the type conversion rules described in section 1.18, Type Conversion, of
http:java.sun.comproductsjspdownloadindex.html .
WebLogic JSP Reference 13-11
The following two conditions must be satisfied when using JSPX:
■
web.xml – The web-app must define the Servlet version attribute as 2.4 or higher; otherwise, all EL functions are ignored.
■
TLD file – Namespace declaration is required for the jsp prefix, as follows: html xmlns:jsp=http:java.sun.comJSPPage;
The following shows a conditional action that uses the JSP EL to test whether a property of a bean is less than 3.
c:if test={bean1.a 3} ...
c:if
Note that the normal JSP coercion mechanism already allows for: mytags:if test=true . There may be literal values that include the character sequence {. If
this is the case, a literal with that value can be used as shown here:
mytags:example code=an expression is {{}expr} The resulting attribute value would then be the string an expression is {expr}.
13.10.2 Expressions and Template Text