How to access bean class attribute through expression language?

Suppose a bean class Person(having name and city) is set in the request scope.
In the servlet:
request.setAttribute(“person”,person);
To get the name of the person,
${person.name} in this case you do not care about what scope the person is in. All you need to care about is that only one person attribute is there (in all scopes).
But if the person attribute is in session scope and also in request scope then there will be naming conflict in above method.
So you can use
${requestScope.person.name} for request scope and
${sessionScope.person.name} for session scope.

No comments:

Post a Comment