1.main.jsp文件代码
<%@page contentType="text/html;charset=utf-8"%>
<html>
<head>输入三角形的的三边长,求面积</head>
<body>
<form action="triangle.jsp" method=post>
<input type="text" name="sizeA" >
<input type="text" name="sizeB" >
<input type="text" name="sizeC" >
<input type="submit" name="submit" value="提交">
</form>
</body>
</html>
2.triangle.jsp文件代码
<%@page contentType="text/html;charset=utf-8"%>
<html>
<body>
<%
String sizeA=request.getParameter("sizeA");
String sizeB=request.getParameter("sizeB");
String sizeC=request.getParameter("sizeC");
double a =Double.parseDouble(sizeA);
double b=Double.parseDouble(sizeB);
double c=Double.parseDouble(sizeC);
double p=(a+b+c)/2,area=0;
area=Math.sqrt(p*(p-a)*(p-b)*(p-c));
out.println("<br>三角形的面积:"+area);
%>
</body>
</html>