Implicit Objects, Scope and EL Expression
Implicit Objects, Scope and EL Expression
Scope and
EL expression
• BY NIDHI GAWAND
IMPLICIT OBJECTS
Implicit objects in JSP (JavaServer Pages) are predefined objects that are
automatically available in the JSP page, providing access to various aspects of
the request, response, and application.
Use page scope for objects created only for the current page.
Objects with page scope are accessible only within the page in
which they are created.
The data is valid only during the processing of the current
response,
Once the response is sent back to the user browser the data is no
longer valid.
If the request is forwarded to another page or the browser
makes another request as a result of a redirect, then such data is
also lost.
EL EXPRESSION
Syntax: `${expression}`
EL Expression Types:
1. Literal Expressions: `${“Hello”}`
2. Expression Statements: `${5 + 5}`
3. Method Calls: `${user.getName()}`
4. Property Access: `${user.name}`
5. List/Array Access: `${users[0]}`
Operators:
1. Arithmetic: `+`, `-`, `*`, `/`, `%`
2. Comparison: `==`, `!=`, `>`, `<`, `>=` , `<=`
3. Logical: `&&`, `||`, `!`
Benefits:
Simplifies JSP code
2. Improves readability
3. Reduces scripting
4. Keep expressions simple.