黑马prince

导航

jsp第五周作业

任务一、教材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 'index.jsp' starting page</title>
    
  </head>
  
  <body bgcolor=cyan>
  <br>英文课本(English Text):
  <p style="font-family:宋体;font-size:18;color:nlack">
  <jsp:include page="任务一素材/english.txt"/>
  <br>课文音频(English Audio):
  <jsp:include page="audio.jsp"></jsp:include>
    </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>
  <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>

 

 

 

 任务二、教材P45  8题

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

<%@ 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 'index.jsp' starting page</title>
  </head>
  
  <body>
  园半径为5<br>
    <jsp:include page="circle.jsp">
    <jsp:param value="5" name="r"/>
    </jsp:include><br>
    梯形上底为3,下底为5,高为4<br>
    <jsp:include page="ladder.jsp">
    <jsp:param value="3" name="s"/>
    <jsp:param value="5" name="x"/>
    <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>
    <base href="<%=basePath%>">
    
    <title>My JSP 'circle.jsp' starting page</title>
    
  </head>
  
  <body>
    圆形面积:
    <%
      String r= request.getParameter("r");
      double bj=Double.parseDouble(r);
      double area=3.14*bj*bj;
      out.print(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>
    <base href="<%=basePath%>">
    
    <title>My JSP 'ladder.jsp' starting page</title>
    
  </head>
  
  <body>
    梯形面积:
    <%
      String s= request.getParameter("s");
      String x= request.getParameter("x");
      String h= request.getParameter("h");
      double sb=Double.parseDouble(s);
      double xb=Double.parseDouble(x);
      double g=Double.parseDouble(h);
      double area=(sb+xb)*g/2;
      out.print(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>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
    <style type="text/css">
div{
    border:1px solid red;
    display: inline;
}
#d1{
    width: 1000px;
    height:100px;
}
#d2{
    width: 500px;
    height:100px;
}
#d3{
    width: 500px;
    height:100px;
}
#d4{
    width: 1000px;
    height:100px;
}
</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="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
main.jsp
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
top.jsp
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
left.jsp
<%@ 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 'ou.jsp' starting page</title>
<style type="text/css">
div {
    border: 1px solid black;
    width: 500px;
    heigh: 250px;
}
</style>

</head>

<body>
    <div align="center">Hello,我是一个偶数!
    
    </div>
</body>
</html>

 

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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
left.jsp

 

 

 任务四、

 

 

 

<%@ 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 'index.jsp' starting page</title>
<style type="text/css">
div {
    border: 1px solid black;
    width: 500px;
    heigh: 250px;
}
</style>
</head>

<body>
    <%
        double a = Math.round(Math.random() * 10);
        if (a % 2 == 0) {
    %>
    
    <jsp:forward page="ou.jsp">
    
    </jsp:forward>
    <%
        
        } else {
    %>
    
    <<jsp:forward page="ji.jsp">
    
    </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>
    <base href="<%=basePath%>">
    
    <title>My JSP 'ji.jsp' starting page</title>
    <style type="text/css">
div {
    border: 1px solid black;
    width: 500px;
    heigh: 250px;
}
</style>

  </head>
  
  <body>
    <div align="center">Hello,我是一个奇数!
    
    </div>
  </body>
</html>

 

posted on 2022-04-02 20:16  HumbleSwag  阅读(7)  评论(0编辑  收藏  举报