For a given EL #{myBean.myProperty}
, following is the steps that are executed by the EL expression evaluator:
- Breaks the EL in two part:The bean is the searched starting from the closest scope to more broader scope.
- First part is the bean name – myBean
- Second part is the property in the bean – myProperty.
- First the bean is searched in request scope.
- If step 3 doesn’t return the bean, then it is searched in view scope.
- If step 4 doesn’t return the bean, then it is searched in session scope.
- If step 5 doesn’t return the bean, then it is searched in the application scope.
- If step 6 doesn’t return the bean, a Runtime Exception is thrown, stating bean cannot be found.
- If bean is found in any of the step from 3 to 6, property is searched in the bean. N.B: The moment bean is found, search for bean will stop immediately.
- If property is found its value is evaluated.
- If property is not found, a Runtime Exception is thrown.