JSP Java Tutorial

< HTML>
    
        Working With Constructors and Inheritance
    
    
        

Working With Constructors and Inheritance


        <%!
            javax.servlet.jsp.JspWriter localOut;
            
            class BaseClass
            {
                BaseClass() throws java.io.IOException 
                {
                    localOut.println("In a\'s constructor...
");
                }
                BaseClass(String s)  throws java.io.IOException
                {
                    localOut.println("In a\'s String constructor...
");
                    localOut.println(s);
                }
            }
            
            class DerivedClass extends BaseClass  
            {
                DerivedClass(String s) throws java.io.IOException 
                {
                    super(s);
                    localOut.println("In b\'s String constructor...
");
                    localOut.println(s);
                }
            }
        %>     
        <%
            localOut = out;     
            DerivedClass obj = new DerivedClass("Hello from JSP!
");
        %>