JSP Java


    
        Using Inheritance
    
    
        

Using Inheritance


        <%!
            javax.servlet.jsp.JspWriter localOut;
            class vehicle
            {
                public void start()  throws java.io.IOException
                {
                    localOut.println("Starting...
");
                }
            }
            class automobile extends vehicle
            {
                public void drive() throws java.io.IOException 
                {
                    localOut.println("Driving...
");
                }
            }
        %>     
        <%
            localOut = out;     
            out.println("Creating an automobile...
");
            automobile a = new automobile();
            a.start();
            a.drive();
        %>