JSP第三次上机作业

任务一、教材P39实验3

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<html>
  <head>    
    <title>My JSP 'index.jsp' starting page</title>    
  </head>  
  <body bgcolor=cyan>
    <br>英文课文(English Text):
    <p style="font-family:宋体;font-size:18;color:black">
    <jsp:include page="english/english.txt"></jsp:include>
    <br>课文音频(English Audio):
    <jsp:include page="audio.jsp"></jsp:include>
    </p>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
  <head>
    <title>My JSP 'audio.jsp' starting page</title>
  </head>
  
  <body bgcolor=pink>
    <embed src="english/english.mp3" autostart=false>
    课文音频
  </body>
</html>

任务二、教材P45  8题

提示:圆形面积需要一个param  梯形面积需要3个param,可以参考教材例2-11

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
  <head>
    <title>My JSP 'main.jsp' starting page</title>
  </head>
  
  <body>
    <jsp:include page="circle.jsp">
    <jsp:param value="5" name="r"/>
    </jsp:include>
    <br>
    <jsp:include page="ladder.jsp">
    <jsp:param value="5" name="a"/>
    <jsp:param value="2" name="b"/>
    <jsp:param value="8" name="h"/>
    </jsp:include>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<html>
  <head>
    <title>求圆的面积</title>
  </head>
  
  <body>
  <%
    String r=request.getParameter("r");
    double bj=Double.parseDouble(r);
    double area=3.14*bj*bj;
    out.print("半径为"+r+"的圆的面积为"+area);
  %>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<html>
  <head>
    <title>求梯形的面积</title>
  </head>
  
  <body>
    <%
    String h=request.getParameter("h");
    String a=request.getParameter("a");
    String b=request.getParameter("b");
    double h1=Double.parseDouble(h);
    double a1=Double.parseDouble(a);
    double b1=Double.parseDouble(b);
    double area=(a1+b1)*h1/2;
    out.print("上底为"+a+"下底为"+b+"高为"+h+"的梯形的面积为"+area);
     %>
  </body>
</html>

任务三、

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
  <head>
    <title>M</title>
    <style type="text/css">
    .box{
    width: 460px;
    height: 90px;
    display:flex;
    justify-content:center;
    align-items:center;
    }
    .top{
    width: 460px;
    height: 30px;
    line-height: 30px;
    background: green;
    text-align: center;
    }
    .left{
    width: 230px;
    height: 30px;
    line-height: 30px;
    background: red;
    text-align: center;
    float:left;
    }
    .main{
    width: 230px;
    height: 30px;
    line-height: 30px;
    background: blue;
    text-align: center;
    float:right;
    }
    .end{
    width: 460px;
    height: 30px;
    line-height: 30px;
    background: yellow;
    text-align: center;
    }
    </style>
  </head>
  
  <body>
  <div class="box">
    <div class="top">
    <jsp:include page="3.top.jsp"></jsp:include>
    </div>
    <div class="left">
    <jsp:include page="3.left.jsp"></jsp:include>
    </div>
    <div class="main">
    <jsp:include page="3.main.jsp"></jsp:include>
    </div>
    <div class="end">
    <jsp:include page="3.end.jsp"></jsp:include>
    </div>
    </div>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
top  十八大精神的那款吗那里是v模块里面<br>
的农夫农家女你放假了吗<br>
的符号接纳三年的克里斯
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
left  的步伐加快不是<br>
的风格i<br>
范德萨拷给你
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
main 从南京<br>
打开手机可<br>
就费劲女金牛对抗肌肤
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
end  大幅低开十六分<br>
打发时间都很过分

任务四、

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
  <head>
    <title>main</title>
  </head>
  
  <body>
    <h1>产生一个0到10的随机整数</h1>
    <%
    double i=Math.round(Math.random()*10);
    if(i%2==0){
     %>
     <jsp:forward page="4.two.jsp">
     <jsp:param value="<%=i %>" name="number"/>
     </jsp:forward>
     <%
     }else{
      %>
      <jsp:forward page="4.one.jsp">
      <jsp:param value="<%=i %>" name="number"/>
      </jsp:forward>
      <%
      }
       %>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
  <head>
    <title>奇数</title>
  </head>
  
  <body>
  <%
  String n=request.getParameter("number");
  out.print("这个随机整数为"+n);
   %>
    <p>Hello,我是一个奇数!</p>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
  <head>
    <title>偶数</title>
  </head>
  
  <body>
  <%
  String n=request.getParameter("number");
  out.print("这个随机整数为"+n);
   %>    
    <p>Hello,我是一个偶数!</p>
  </body>
</html>

 

posted @ 2022-03-30 13:29  小猪哏哏  阅读(23)  评论(0编辑  收藏  举报