Using jsp getProperty to get value from java bean : Get Set Property « JSP « Java Tutorial






Jsp code

<HTML>
  <HEAD>
    <TITLE>Getting a Property Value</TITLE>
  </HEAD>
  <BODY>

    <H1>Getting a Property Value</H1>

    <jsp:useBean id="bean1" class="beans.Test4" />

    The message is: <jsp:getProperty name="bean1" property="message" /> 
  </body>
</html>

Test4.java

package beans;

import java.io.Serializable;

public class Test4 implements Serializable
{

    public Test4() 
    {
    }
    private String message = "Hello from JSP!";

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

    public String getMessage() 
    {
        return this.message;
    }

}
  Download:  UsingJspGetPropertyToGetValueFromJavaBean.zip( 2 k)








23.42.Get Set Property
23.42.1.Using jsp getProperty to get value from java bean
23.42.2.Using setter to change value and read it back by jsp get property