Source Code : Calling a Private Method

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Calling a Private Method

// 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() 
    {
    }
}
           
       

Thank with us