<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <html> <head> </head> <body> <%!double r = 1, a = 2, b = 3, c = 4;%> <br>计算半径为<%=r%>的圆的面积: <jsp:include page="circle.jsp"> <jsp:param value="<%=r %>" name="name3" /> </jsp:include> <p>---------------------------------------------------------------------</p> <br>计算上底、下底、高为<%=a%>,<%=b%><%=c%>的梯形面积 <jsp:include page="ladder.jsp"> <jsp:param value="<%=a %>" name="name1" /> <jsp:param value="<%=b %>" name="name2" /> <jsp:param value="<%=c %>" name="name3" /> </jsp:include> </body> </html>
<%@page contentType="text/html;charset=utf-8"%> <% String name1 = request.getParameter("name1"); String name2 = request.getParameter("name2"); String name3 = request.getParameter("name3"); double a = Double.parseDouble(name1); double b = Double.parseDouble(name2); double c = Double.parseDouble(name3); %> <%!public String getArea(double a, double b, double c) { double area = ((a + b) * c) / 2; return "" + area; }%> <br> <br> 梯形的上底、下底、高是: <%=name1%> <%=name2%> <%=name3%> <br> 梯形的面积是: <%=getArea(a, b, c)%>
<%@page contentType="text/html;charset=utf-8"%> <% String sideR = request.getParameter("name3"); double r = Double.parseDouble(sideR); %> <%! public String getArea(double r) { double area = r * r * 3.14; return "" + area; }%> <br> <br> 圆的半径是:<%=r%> <br> 圆的面积是:<%=getArea(r)%>