第三次作业

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

<%@ 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><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"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <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"%>
<%
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>
    <title>My JSP 'main.jsp' starting page</title>
  </head>
  <body>
    <jsp:include page="circle.jsp">
    <jsp:param value="2" name="r"/>
    </jsp:include>
    <br>
    <jsp:include page="ladder.jsp">
    <jsp:param value="2" name="a"/>
    <jsp:param value="3" name="b"/>
    <jsp:param value="4" name="h"/>
    </jsp:include>
  </body>
</html>
<%@ 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>
    <title>My JSP 'circle.jsp' starting page</title>
  </head>
  <body>
    <%!double getarea(double r){
           double area=3.14*r*r;
           return area;
   } %>
   <%
   String r=request.getParameter("r");
   double r1=Double.parseDouble(r);
   double area=getarea(r1);
   out.print("圆形的半径是"+r+",圆形的面积:"+area);
    %>
  </body>
</html>
<%@ 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>
    <title>My JSP 'ladder.jsp' starting page</title>
  </head>
  
  <body>
    <%
    String a=request.getParameter("a");
    String b=request.getParameter("b");
    String h=request.getParameter("h");
    double a1=Double.parseDouble(a);
    double b1=Double.parseDouble(b);
    double h1=Double.parseDouble(h);
    double area=(a1+b1)*h1/2;
    out.print("上底为"+a+"下底为"+b+"高为"+h+"的梯形的面积为"+area);
     %>
  </body>
</html>

3.任务三、详见Word图片

<%@ 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>
<title>My JSP 'index.jsp' starting page</title>

</head>

<body>
    <table border="1" align="center" bgcolor="yellow">
        <tr align="center">
            <td colspan="2"><jsp:include page="top.jsp"></jsp:include>
        <tr align="center">
            <td><jsp:include page="left.jsp"></jsp:include></td>
            <td><jsp:include page="main.jsp"></jsp:include></td>
        <tr align="center">
            <td colspan="2"><jsp:include page="end.jsp"></jsp:include>
    </table>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%="top.jsp的文件内容包含在这里 "%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%="left.jsp的文件内容包含在这里 "%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%="main.jsp的文件内容包含在这里 "%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%="end.jsp的文件内容包含在这里 "%>

4.任务四、详见Word图片

 

<%@ 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>

<title>My JSP 'index.jsp' starting page</title>

</head>

<body>
    <%
        int i = (int) (Math.random() * 10 + 1);
        if (i % 2 == 0) {
    %>

    <jsp:forward page="hh.jsp">
        <jsp:param value="<%=i%>" name="num" />
    </jsp:forward>
    <%
        } else {
    %>
    <jsp:forward page="mm.jsp">
        <jsp:param value="<%=i%>" name="num" />
    </jsp:forward>
    <%
        }
    %>
</body>
</html>
<%@ 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>
    
    <title>My JSP 'ji.jsp' starting page</title>

  </head>
  
  <body>
 <%
 String m=request.getParameter("num");
 int n=Integer.parseInt(m);
 out.print("随机数为"+n+"<br>");
  %>
  Hello,我是一个奇数!
  </body>
</html>
<%@ 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>
    
    <title>My JSP 'ou.jsp' starting page</title>


  </head>
  
  <body>
   <%
 String m=request.getParameter("num");
 int n=Integer.parseInt(m);
 out.print("随机数为"+n+"<br>");
  %>
  Hello,我是一个偶数!
  </body>
</html>

 

posted @ 2022-04-02 20:02  无言De钉钉  阅读(24)  评论(0编辑  收藏  举报