Saturday, 17 December 2011

JSP Examples Tutorial - Using Inheritance in JSP


<HTML>
    <HEAD>
        <TITLE>Using Inheritance</TITLE>
    </HEAD>
    <BODY>
        <H1>Using Inheritance</H1>
        <%!
            javax.servlet.jsp.JspWriter localOut;
            class BaseClass
            {
                public void start()  throws java.io.IOException
                {
                    localOut.println("Starting...<BR>");
                }
            }
            class DerivedClass extends BaseClass
            {
                public void drive() throws java.io.IOException 
                {
                    localOut.println("Deriving...<BR>");
                }
            }
        %>     
        <%
            localOut = out;     
            out.println("Creating an DerivedClass...<BR>");
            DerivedClass a = new DerivedClass();
            a.start();
            a.drive();
        %>
    </BODY>
</HTML>

No comments:

Post a Comment