JSP第五周作业

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>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'audio.jsp' starting page</title>
    
  </head>
  
  <body bgcolor=pink>
  <embed src="任务一素材/english.mp3"autostart=false>
    课文音频
    </embed>
  </body>
</html>
<%@ page contentType="textml"%> 
<%@ page 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 'index.jsp' starting page</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>
<ml>

 

 
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+"/";
%>
 <%!double r=(int)(Math.random()*10)+1; %>
<jsp:include page="circle.jsp">
<jsp:param name="r" value="4"/>
</jsp:include>
<br>
<jsp:include page="ladder.jsp">
<jsp:param name="a" value="4"/>
<jsp:param name="b" value="4"/>
<jsp:param name="c" value="4"/>
</jsp:include>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>My JSP 'index1.jsp' starting page</title>
  </head>
  <body>
 
   
   
  </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>

 

   3.任务三、 

<%@ 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"%>
<%
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 'index1.jsp' starting page</title>
  </head>
  <body>
    <%
  String r=request.getParameter("i");
  int x=Integer.parseInt(r);
  out.print("随机数"+x); %>
    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>
    <base href="<%=basePath%>">
    <title>My JSP 'index1.jsp' starting page</title>
  </head>
  <body>
  <%
  String r=request.getParameter("i");
  int x=Integer.parseInt(r);
  out.print("随机数"+x); %>
  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>
<base href="<%=basePath%>">
<title>My JSP 'index1.jsp' starting page</title>
</head>
<body>
    <%
        int i = (int) (Math.random() * 10 + 1);
        if (i % 2 == 0) {
    %>
    <jsp:forward page="o.jsp">
        <jsp:param value="<%=i %>" name="i" />
    </jsp:forward>
    <%
        } else {
    %>
    <jsp:forward page="j.jsp">
        <jsp:param value="<%=i %>" name="i" />
    </jsp:forward>
    <%
        }
    %>
</body>
</html>

 

posted @ 2022-04-02 17:54  kgbk  阅读(13)  评论(0编辑  收藏  举报