jsp: getProperty tag

jsp: getProperty tag

The jsp: getProperty tag is used to retrieve the property from the instance of javaBeans. The following is the syntax of jsp: getProperty tag:


<jsp: getProperty name = “name of bean” property = “property of bean” / >

In the above syntax the name attribute is used to specify the name of the instance of the JavaBean, the attribute property is used to specify the property of the JavaBean whose value the user wants to get.


Example of getProperty with JavaBean:

Consider the following example in which we have a java class and a JSP page and we used the jsp: getProperty tag to print the value of the property:

EmployeeBean. java:

import java.io.Serializable;

public class EmployeeBean implements Serializable


 private String n;

  public EmployeeBean()


    this. n = “”;


   public void settingName (String n)


    this. n = n;


   public String gettingName ()


    return n;




< html >

< head >

< title >JSP Page < /title >

</ head >

<jsp: useBean id = “employee” class = “EmployeeBean” scope = “request” / >

< body >

Beans: < jsp: getProperty name = “employee” property = “name of property” / >

</ body >

</ html >

In the above example the jsp: useBean tag is used to declare a bean named as “employee” in the JSP page. And the value of the property will be printed. We can also set the value of property if we want to change the value of property by using the jsp: setProperty tag. This will be discussed in the next session.