JSP第三次作业

cricle

<%@ 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>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'cricle.jsp' starting page</title>
    
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->

  </head>
  
  <body>
   <%     String r = request.getParameter("R"); 
           int R = Integer.parseInt(r);
           out.print("园的半径为:"+ r +"   "+ "园的面积为:" + 3.14 * R * R);
       %>
  </body>
</html>

ladder

<%@ 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>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'ladder.jsp' starting page</title>
    
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->

  </head>
  
  <body>
   <%
        String shangdi = request.getParameter("shangdi");
        String xiadi = request.getParameter("shangdi");
        String gao = request.getParameter("xiadi"); 
        int shang = Integer.parseInt(shangdi);
        int xia = Integer.parseInt(xiadi);
        int g = Integer.parseInt(gao);
        out.println("上底为:" + shangdi + ",下底为:" + xiadi + ",高为:" + gao);
        out.print("梯形的面积为:" + ((shang + xia) * g) / 2);
    %>
  </body>
</html>

main

<%@ 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>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'main.jsp' starting page</title>
    
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->

  </head>
  
  <body>
    <jsp:include page="cricle.jsp">
        <jsp:param value="12" name="R"/>
    </jsp:include>
    <br>
 <jsp:include page="ladder.jsp">
        <jsp:param value="6" name="shangdi"/>
        <jsp:param value="3" name="xiadi"/>
        <jsp:param value="3" name="gao"/>
    </jsp:include>
  </body>
</html>

posted @ 2020-03-21 20:01  阿点  阅读(97)  评论(0编辑  收藏  举报