Tuesday, July 15, 2008

Jsp:getProperty

Syntax

<-jsp:getProperty name="beanInstanceName" property="propertyName" />

Example

<-jsp:useBean id="calendar" scope="page" class="employee.Calendar" />
Calendar of <-jsp:getProperty name="calendar" property="username" />

Description

The element gets a Bean property value using the property's getter methods and displays the property value in a JSP page. You must create or locate a Bean with before you use .

The element has a few limitations you should be aware of:

* You cannot use to retrieve the values of an indexed property.
* You can use with JavaBeans components, but not with enterprise beans. As alternatives, you can write a JSP page that retrieves values from a Bean that in turn retrieves values from an enterprise bean, or you can write a custom tag that retrieves values from an enterprise bean directly.

Attributes

# name="beanInstanceName"

The name of an object (usually an instance of a Bean) as declared in a element.
# property="propertyName"

The name of the Bean property whose value you want to display. The property is declared as a variable in a Bean and must have a corresponding getter method (for more information on declaring variables and writing getter methods in Beans, see the JavaBeans API Specification).

No comments: