JSP syntax (9)

Source: Internet
Author: User

<Jsp: getProperty>

Obtains the Bean property value, which is displayed on the page.

JSP syntax

<Jsp: getProperty name = "beanInstanceName" property = "propertyName"/>

Example

<Jsp: useBean id = "calendar" scope = "page" class = "employee. Calendar"/>

<H2>

Calendar of <jsp: getProperty name = "calendar" property = "username"/>

</H2>

Description

The <jsp: getProperty> element obtains the Bean property value and can be used or displayed on the JSP page. before using <jsp: getProperty>, you must use <jsp: useBean> to create it.

<Jsp: getProperty> elements have some restrictions:

You cannot use <jsp: getProperty> to retrieve an indexed property.

You can use <jsp: getProperty> with the JavaBeans component, but not with the Enterprise

Bean.

Attribute

Name = "beanInstanceName"
Bean name, specified by <jsp: useBean>

Property = "propertyName"
Attribute name of the specified Bean.

TIPS:

As mentioned in sun's JSP reference, if you use <jsp: getProperty> to retrieve a value that is null, NullPointerException will occur. If you use a program segment or expression to retrieve the value, in the browser, null is displayed ).

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.