16.2 Invoking the Expression Language

In JSP 2.0, you invoke the expression language with elements of the following form.

 ${  expression  } 

These EL elements can appear in ordinary text or in JSP tag attributes, provided that those attributes permit regular JSP expressions. For example:

 <UL>   <LI>Name:  ${   expression1   }  <LI>Address:  ${   expression2   }  </UL> <jsp:include page="  ${   expression3   }  " /> 

When you use the expression language in tag attributes, you can use multiple expressions (possibly intermixed with static text) and the results are coerced to strings and concatenated . For example:

 <jsp:include page="  ${expr1}blah${expr2}  " /> 

This chapter will illustrate the use of expression language elements in ordinary text. Volume 2 of this book will illustrate the use of EL elements in attributes of tags that you write and tags that are provided by the JSP Standard Tag Library (JSTL) and JavaServer Faces (JSF) libraries.

Escaping Special Characters

If you want ${ to appear in the page output, use \${ in the JSP page. If you want to use a single or double quote within an EL expression, use \' and \" , respectively.

Core Servlets and JavaServer Pages (Vol. 1.Core Technologies)
Core Servlets and Javaserver Pages: Core Technologies, Vol. 1 (2nd Edition)
ISBN: 0130092290
EAN: 2147483647
Year: 2002
Pages: 194

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net