jsp expression language
Download
Skip this Video
Download Presentation
JSP Expression Language

Loading in 2 Seconds...

play fullscreen
1 / 12

JSP Expression Language - PowerPoint PPT Presentation


  • 210 Views
  • Uploaded on

JSP Expression Language. Celsina Bignoli bignolic@smccd.net. Expression Language. Introduced as part of standard JSP in version 2.0 simple expression language for accessing variables starts with the ${ delimiter and ends with } ${anExpression} Case sensitive. All keywords are lowercase.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'JSP Expression Language' - nassor


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
jsp expression language

JSP Expression Language

Celsina Bignoli

bignolic@smccd.net

expression language
Expression Language
  • Introduced as part of standard JSP in version 2.0
  • simple expression language for accessing variables
  • starts with the ${ delimiter and ends with }

${anExpression}

  • Case sensitive. All keywords are lowercase
using expressions
Using Expressions
  • in static text
    • The value of the expression is computed and inserted into the current output
  • In any standard or custom tag attribute that can accept an expression

    • The expression is evaluated and the result is coerced to the attribute's expected type

    • The expressions are evaluated from left to right. Each expression is coerced to a String and then concatenated with any intervening text. The resulting String is then coerced to the attribute's expected type.
variables
Variables
  • The web container evaluates a variable that appears in an expression by looking up its value according to the behavior of PageContext.findAttribute(String).
  • For example, when evaluating the expression ${product}, the container will look for product in the following scopes:
    • page
    • request
    • session
    • application
  • If product is not found, null is returned.
variables1
Variables
  • Properties of variables are accessed using the “. “ operator and can be nested arbitrarily
  • For example:
    • ${pageContext.session}
    • ${myBean.attribute1.attribute2}
implicit variables
Implicit Variables
  • pageContext: The context for the JSP page. Provides access to various other objects including:
    • session: The session object for the client.
    • request: The request triggering the execution of the JSP page.
    • response: The response returned by the JSP page.
implicit variables1
Implicit Variables
  • param: Maps a request parameter name to a single value
  • paramValues: Maps a request parameter name to an array of values
  • header: Maps a request header name to a single value
  • headerValues: Maps a request header name to an array of values
  • cookie: Maps a cookie name to a single cookie
  • initParam: Maps a context initialization parameter name to a single value
implicit variables2
Implicit Variables
  • pageScope: Maps page-scoped variable names to their values
  • requestScope: Maps request-scoped variable names to their values
  • sessionScope: Maps session-scoped variable names to their values
  • applicationScope: Maps application-scoped variable names to their values
literals
Literals
  • The JSP expression language defines the following literals:
    • Boolean: true and false
    • Integer: as in Java
    • Floating point: as in Java
    • String: with single and double quotes; " is escaped as \", ' is escaped as \', and \ is escaped as \\.
    • Null: null
literals1
Literals
  • the JSP expression language provides the following operators:
    • Arithmetic: +, - (binary), *, / and div, % and mod, - (unary)
    • Logical: and, &&, or, ||, not, !
    • Relational: ==, eq, !=, ne, <, lt, >, gt, <=, ge, >=, le. Comparisons can be made against other values, or against boolean, string, integer, or floating point literals.
    • Empty: The empty operator is a prefix operation that can be used to determine whether a value is null or empty.
    • Conditional: A ? B : C. Evaluate B or C, depending on the result of the evaluation of A.
reserved words
Reserved Words
  • The following words are reserved for the JSP expression language and should not be used as identifiers:

and   eq   gt   true   instanceof or    ne   le   false  empty not   lt   ge   null   div   mod

example
Example
  • ${4.0 > 3} true
  • ${empty param.add} true if parameter add in the request is null or empty string
  • ${pageContext.request.contextPath} The context path
  • ${sessionScope.cart.numberOfItems} The value of the numberOfItems property of the session-scoped attribute named cart
ad