How to Use Inheritence in the jsp
<%!
javax.servlet.jsp.JspWriter pw;
class Rectangle
{
int length =10;
int breadth =20 ;
public int areaOfRectangle() throws java.io.IOException
{
pw.println("Calculating the area of a rectangle...
");
return(length*breadth);
}
}
class Square extends Rectangle
{
public int areaOfSquare() throws java.io.IOException
{
pw.println("Calculating the area of a square...
");
return(length*length);
}
}
%>
<%
pw = out;
Square sq = new Square();
int area1 = sq.areaOfRectangle();
out.println(area1);
out.println("
");
int area2 = sq.areaOfSquare();
out.println(area2);
%>