GetProperty Tag in JSP

The getProperty action is used to retrieve the value of a given property and converts it to a string, and finally inserts it into the output.

The getProperty action has only two attributes, both of which are required ans simple syntax is as follows:

<jsp:useBean id="myName" ... />
<jsp:getProperty name="myName" property="someProperty" .../>

Explanation: As shown above, getProperty tag in JSP has two attributes “name” and “property”. Please note that jsp:getProperty tag must be used with jsp:useBean tag.

  • name Attribute: name attribute in JSP getProperty tag must match with useBean Tag. If JSP has multiple useBean tag, id of the useBean tag is used to identify the bean. While getting property of that bean, id in useBean tag must match with name attribute in getProperty Tag.
  • property Attribute: property attribute in JSP getProperty Tag idnetifies the property whose value is being requested by this tag.


package com.dineshonjava.bean;

 * @author Dinesh Rajput
public class Employee {
 private String firstName;
 private String lastName;
 private String address;
 public String getFirstName() {
  return firstName;
 public void setFirstName(String firstName) {
  this.firstName = firstName;
 public String getLastName() {
  return lastName;
 public void setLastName(String lastName) {
  this.lastName = lastName;
 public String getAddress() {
  return address;
 public void setAddress(String address) {
  this.address = address;


<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
  <h1>Employee Form Bean Value</h1>
    <jsp:useBean id="emp" class="com.dineshonjava.bean.Employee" scope="page" />
    <jsp:setProperty name="emp" property="firstName" value="Dinesh"/>
    <jsp:setProperty name="emp" property="lastName" value="Rajput"/>
    <jsp:setProperty name="emp" property="address" value="Noida"/>
       <td>First Name</td>
       <td> : </td>
       <td> <jsp:getProperty name="emp" property="firstName"/> </td>
       <td>Last Name</td>
       <td> : </td>
       <td> <jsp:getProperty name="emp" property="lastName"/> </td>
       <td> : </td>
       <td> <jsp:getProperty name="emp" property="address"/> </td>

Copy myapp folder on webapp directory of tomcat at
C:Program Files (x86)Apache Software FoundationTomcat 7.0webapps

and restart server and hit the following URL

Download Example

<<Previous <<   || Index ||   >>Next >>