// JSP file
<HTML>
<HEAD>
<TITLE>Calling a Private Method</TITLE>
</HEAD>
<BODY>
<H1>Calling a Private Method</H1>
<jsp:useBean id="bean1" class="beans.Message" />
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>
///////////////////////////////////////
//Java Source Code
package beans;
import java.io.Serializable;
public class Message implements Serializable
{
private String message = "Hello from JSP!";
public void setMessage(String m)
{
this.message = m;
}
public String getMessage()
{
return privateMessage();
}
private String privateMessage()
{
return this.message;
}
public Message()
{
}
}
|