JSP programming (II)-JSP basic syntax (8)-JSP: getproperty

Source: Internet
Author: User

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<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 EnterpriseBean.

       

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 null valueNullpointerexception will occur.ProgramSegment or expression to retrieve its value, then null (null) appears in the browser ).
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.