jsp第五周作业

1.任务一、教材P39实验3

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>英语课文</title>
</head>
 
<body bgcolor="cyan">
    <br>英文课文(English Text):</br>
    <p style="font-family: 宋体;font-size: 18;color: black">
        <jsp:include page="english/english.txt" />
        <br>课文音频(English Audio):</br>
        <jsp:include page="audio.jsp" />
    </p>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>课文音频</title>
</head>
<body bgcolor=pink>
    <embed src="english/english.mp3" autostart="false">
    课文音频
    </embed>
</body>
</html>

 

 2.任务二、教材P45  8题

<%@ 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="10" name="r"/>
  </jsp:include>
  <br>
  <jsp:include page="ladder.jsp">
  <jsp:param value="10" name="shang"/>
  <jsp:param value="20" name="xia"/>
  <jsp:param value="2" name="gao"/>
  </jsp:include>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
  <head>
    <title>My JSP 'main.jsp' starting page</title>
  </head>
  
  <body>
  圆面积
  <%
  String r=request.getParameter("r");
  double a=Double.parseDouble(r);
  double s=a*a*3.14;
  out.println(s);
  
   %>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
  <head>
    <title>My JSP 'main.jsp' starting page</title>
  </head>
  
  <body>
  梯形面积
  <%
  String shang=request.getParameter("shang");
  String xia=request.getParameter("xia");
  String gao=request.getParameter("gao");
  double a=Double.parseDouble(xia);
  double b=Double.parseDouble(xia);
  int c=Integer.parseInt(gao);
  double s=(a+b)*c/2;
  out.println(s);
  
   %>
  </body>
</html>

 

 

3.任务三、详见Word图片

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

<html>
<head>
<title>My JSP 'end.jsp' starting page</title>
<style type="text/css">
div{
    border:1px solid red;
    display: inline;
}
#d1{
    width: 400px;
}
#d2{
    width: 200px;
}
#d3{
    width: 200px;
}
#d4{
    width: 400px;
}
</style>
</head>
<body>
    <hr align="center" color="red">
    <div id="d1" align="center">
    <jsp:include page="top.jsp"></jsp:include>
    </div>
    <br>
    <div id="d2" align="center">
    <jsp:include page="left.jsp"></jsp:include>
    </div>
    <div id="d3" align="center">
    <jsp:include page="main.jsp"></jsp:include>
    </div>
    <br>
    <div id="d4" align="center">
    <jsp:include page="end.jsp"></jsp:include>
    </div>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<html>
  <head>
    <title>My JSP 'end.jsp' starting page</title>
  </head>
  <body>
    This is end.jsp. <br>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<html>
  <head>
    <title>My JSP 'end.jsp' starting page</title>
  </head>
  <body>
    This is left.jsp. <br>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<html>
  <head>
    <title>My JSP 'end.jsp' starting page</title>
  </head>
  <body>
    This is main.jsp. <br>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<html>
  <head>
    <title>My JSP 'end.jsp' starting page</title>
  </head>
  <body>
    This is top.jsp. <br>
  </body>
</html>

 

 

4.任务四、详见Word图片

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>奇偶</title>
  </head>
  <body>
    <%
        int i = (int) (Math.random() * 10 + 1);
        if(i%2==0){
      %>
     <jsp:include page="ou.jsp"/>
     <%
        }else{
      %>
     <jsp:include page="ji.jsp"/>
     <%
         }
      %>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>奇数</title>
  </head>
  <body>
    <table border="1">
        <tr><th>Hello,我是一个奇数</th></tr>
    </table>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>偶数</title>
  </head>
  <body>
    <table border="1">
        <tr><th>Hello,我是一个偶数</th></tr>
    </table>
  </body>
</html>

 

posted @ 2022-04-03 15:43  计算机1902佟阳  阅读(22)  评论(0编辑  收藏  举报