Accessing Bean Properties
Beans are objects: structured variables that instead of holding a single
value, hold a set of related values called properties. A
PresentationArticle
bean, for example, has more than 40 properties describing various
aspects of a content item. Its articleId
property
contains a unique ID for the content item, its
createdDateAsDate
property contains the date on which
it was created, its author
property is another bean
containing information about the author of the content item.
You can access these properties with the JSP expression language by
using dot notation
. You simply add the name of the
property you are interested in to the end of the bean name, separated by
a dot. To access the article
request bean's
articleId
property, for example, you can use:
${article.articleId}
A bean property may be a reference to another bean rather than a simple
string or number. PresentationArticle
's
author
property, for example, is a reference to a
Person
bean. In this case, you can use the same
notation to access that bean's properties. You can, for example access
the name of the author of a content item as follows:
${article.author.name}