Get/Set Value Using JSP Set Property : UseBean « 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" /> 
        <BR>
        <jsp:setProperty name="bean1" property="message" value="Hello again!" />

        Now 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:  GetSetValueUsingJspSetProperty.zip( 2 k)








23.43.UseBean
23.43.1.Import JavaBeans In JSP Page
23.43.2.Load JavaBeans In JSP Page
23.43.3.Using 'useBean' To Reference A Java Bean
23.43.4.Using initialized field in jsp page
23.43.5.Reference Package Name in JSP Page
23.43.6.Reference Calendar Bean
23.43.7.JSP Number Guess Bean
23.43.8.JSP Helper Bean HTMLFilter
23.43.9.Get/Set Value Using JSP Set Property
23.43.10.Call Setter In Java Bean To Change its Property Value
23.43.11.Call Bean Constructor To Pass In Message
23.43.12.Using the Date Class
23.43.13.Fields of the Calendar Class