main.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <body> <%double r=2,a=3,b=4,h=5; %> <br>circle <jsp:include page="circle.jsp"> <jsp:param value="<%= r %>" name="R"/> </jsp:include> <br>ladder <jsp:include page="ladder.jsp"> <jsp:param value="<%= a %>" name="A"/> <jsp:param value="<%= b %>" name="B"/> <jsp:param value="<%= h %>" name="H"/> </jsp:include> </body> </html>
circle.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <body> <% String R=request.getParameter("R"); double r=Double.parseDouble(R); double mj=r*r*3.14; %> <br>传递的半径是:<%=r%> <br>圆的面积是:<%=mj%> </body> </html>
ladder.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <body> <% String A=request.getParameter("A"); String B=request.getParameter("B"); String H=request.getParameter("H"); double a=Double.parseDouble(A); double b=Double.parseDouble(B); double h=Double.parseDouble(H); double area=(a+b)*h/2; %> <br>传递的上底、下底、高是:<%=A%> <%=B %> <%=H%> <br>梯形面积:<%=area %> </body> </html>