JSP 三次作业

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<HTML><body bgcolor = cyan>
	<br>英文课文(English Text): </br>
	<p style="font-family: 宋体; fong-size: 18; color: black">
	<jsp:include page="english/english.txt" />
	</p>
	<br>课文音频(English Audio): </br>
	<jsp:include page = "audio.jsp" />
	</p>
</body></HTML>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8" contentType="text/html" %>
<HTML><body>

<embed src="english/english.mp3" autostart=false>
课文音频
</embed>
</body></HTML>

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
    <body>
<%
    double r=3,a=2,b=5,c=2;
 %>
 <br>circle.jsp计算半径为<%=r %>的圆的面积:
     <jsp:include page="circle.jsp">
         <jsp:param value="<%=r %>" name="sideR"/>
     </jsp:include>
     <p>---------------------------------------------------------------------</p>
 <br>ladder.jsp计算上底、下底、高为<%=a %>,<%=b %><%=c %>的梯形面积
     <jsp:include page="ladder.jsp">
         <jsp:param value="<%=a %>" name="sideA"/>
         <jsp:param value="<%=b %>" name="sideB"/>
         <jsp:param value="<%=c %>" name="sideC"/>
     </jsp:include>
    </body>    
</html>

<%@ page language="java" import="java.util.*" pageEncoding="utf-8" contentType="text/html" %>
<%!    public String getArea(double r)
    {
        if(r>0)
        {
            double area=r*r*3.14;
            return ""+area;
        }
        else{
            return("半径为"+r+"不能为大于0以外的数字,无法计算面积");
        }
    }
%>
<%
    String sideR=request.getParameter("sideR");
    double r=Double.parseDouble(sideR);
%>
<br><br>计算元的面积<br>
半径 <%=r%>
<br>圆的面积是:<%=getArea(r) %>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8" contentType="text/html" %>
<%!    public String getArea(double a,double b,double c)
    {
        if(a>0&&b>0&&c>0)
        {
            double area=(a+b)*c/2;
            return ""+area;
        }
        else{
            return("梯形的上底、下底、高"+a+" "+b+" "+c+"不能为大于0以外的数字,无法计算面积");
        }
    }
%>
<%
    String sideA=request.getParameter("sideA");
    String sideB=request.getParameter("sideB");
    String sideC=request.getParameter("sideC");
    double a=Double.parseDouble(sideA);
    double b=Double.parseDouble(sideB);
    double c=Double.parseDouble(sideC);
%>
<br><br>ladder.jsp 负责计算圆的面积<br>
上底、下底、高是:<%=sideA%> <%=sideB %>  <%=sideC %>

<br>梯形的面积是:<%=getArea(a,b,c) %>


<%@ page language="java" import="java.util.*" pageEncoding="utf-8" contentType="text/html" %>
<%!    public String function(int _number)
    {
        return _number % 2 == 0 ? "偶数" : "奇数";
    }
%>
<html>

<body>
	<p>3 是 <%=function(3) %></p>
	<p>4 是 <%=function(4) %></p>
</body>



</html>

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
	    .col {
	        /* 设置显示为grad */
	        display: grid;
	        /* 默认显示为行 */
	        grid-auto-flow: row;
	        /* 修改为列显示 */
	        grid-auto-flow: column;
	        /* 显示为三行三列 */
	        grid-template-columns: 100px 100px 100px;
	        grid-template-rows: 200px 200px;
	        /* 对于放不下的项目,会掩式生成单元格 */
	        grid-auto-rows: auto;
	    }
    </style>
</head>

<body>
    <div id="template" class="template-1col">
        <jsp:include page="1.jsp" />
    </div>
    <div id="template" class="template-1col">
        <jsp:include page="2.jsp" />
    </div>
    <div id="template" class="template-1col">
        <jsp:include page="3.jsp" />
    </div>
    <div id="template" class="template-1col">
        <jsp:include page="4.jsp" />
    
    </div>
</body>
</html>


<div>page 1</div>
<div>page 2</div>
<div>page 3</div>
<div>page 4</div>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
	    .col {
	        /* 设置显示为grad */
	        display: grid;
	        /* 默认显示为行 */
	        grid-auto-flow: row;
	        /* 修改为列显示 */
	        grid-auto-flow: column;
	        /* 显示为三行三列 */
	        grid-template-columns: 100px 100px 100px;
	        grid-template-rows: 200px 200px;
	        /* 对于放不下的项目,会掩式生成单元格 */
	        grid-auto-rows: auto;
	    }
    </style>
</head>

<body>
    <div id="template" class="template-1col">
        <jsp:include page="1.jsp" />
    </div>
    <div id="template" class="template-1col">
        <jsp:include page="2.jsp" />
    </div>
    <div id="template" class="template-1col">
        <jsp:include page="3.jsp" />
    </div>
    <div id="template" class="template-1col">
        <jsp:include page="4.jsp" />
    
    </div>
</body>
</html>


posted @ 2022-04-03 09:06  SuoJing  阅读(18)  评论(0编辑  收藏  举报