Expression Language - EL
Introduction to Expression Language
Introduction to Expression Language
The Expression Language (EL) simplifies the data accessibility from various type of application objects like Java Beans, request, session and application etc. There are many implicit objects, operators and reserve words in EL. It is the newly added feature in JSP technology version 2.0.
Syntax
Syntax
${expression}
${EL.Statement}
${attrName}
${attrName[index]}
${OneObject.MemeberObject.PropertyNameOfMemberObject}
EL implicit object
EL implicit object
- param
- paramValues
- header
- headerValues
- cookie
- pageScope
- requestScope
- session’scope
- applicationScope
- initParam
- pageContext(*)
param and paramValues
param and paramValues
- These two EL implicit objects are used to collect the request parameters and its values
- When param is used then internally request.getParameter() method will be called
- When paramValues is user then internally request.getParameterValues() will be called
Usage:
Usage:
${param.name}
${param.course}
${paramValues.course[0]}
${ paramValues.course[1]}
header and header values
header and header values
- These two EL implicit objects are used to collect the request headers
- When header is used then internally request.getHeader() method will be called
- When headerValues is used then internally request.getHeaderValues() will be called
Usage:
Usage:
${header.host}
${header.referer}
${headrValues.accept-language[0]}
${headrValues.accept-language[1]}
initParam
initParam
- This EL implicit object is used to collect the context parameters from
ServletContext
obj
Usage:
Usage:
${initParam.institute}
${initParam.website}
pageContext
pageContext
- This EL implicit object allows to access all other JSP implicit objects and their properties
Usage:
Usage:
${pageContext.session.id}
${pageContext.session.length}
${pageContext.request.removeAddr}
${pageContext.request.method}
${pageContext.request.requestURL}
${pageContext.request.contentType}
pageScope, requestScope, sessionScope, applicationScope
pageScope, requestScope, sessionScope, applicationScope
- In servlet class, you can store the data as attribute
- In JSP, you can collect the attribute data and display that data
- You can store the following type of data as attribute in the required scope
- String, Wrappers and Date
- Collection of String, Wrappers and Date(****JSTL)
- Collection of Collections(****JSTL)
- User defined objects eg: Student, User, Book
- Collection of user defined object
- Map object
- Collection of Map objects(****JSTL)
EL - String, Wrappers and Date
EL - String, Wrappers and Date
EL - Collection of String, Wrappers and Date
EL - Collection of String, Wrappers and Date
User defined objects
User defined objects
Collection of user defined objects
Collection of user defined objects
Map objects
Map objects
Collection of maps
Collection of maps