This example shows the way of getting and setting the property of a JavaBean class. This example uses <jsp:useBean>, <jsp:getProperty> and <jsp:setProperty> tags of the JSP.

The following JSP page sets and gets the message property to value “Hello Rohit” of Simple Bean.

<titile>Demo resuing java beans in jsp</title>
<table border = 5>
Re using javaBeans in JSP </table>
<jsp:useBean id ="test" class="beans.SimpleBean"/>
<jsp:setProperty name="test" property="message" value="Hello Rohit"/>
<h1>Message: <i>
<jsp:getProperty name = "test" property="message"/>

public class SimpleBean {

  private String message = "No message specified";

  public String getMessage() {
    return message;
  public void setMessage(String message) {
    this.message = message;