jsp第5周作业

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 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 'listenEnglish.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>

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>
    <base href="<%=basePath%>">
    <title>My JSP 'index.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>
    <base href="<%=basePath%>">
    <title>My JSP 'index.jsp' starting page</title>
  </head>
  <body>
     <%!double getarea(double s,double x,double g){
           double area=(s+x)*g/2;
           return area;
   } %>
   <%
   String string=request.getParameter("s");
   double s1=Double.parseDouble(string);
   string=request.getParameter("x");
   double x1=Double.parseDouble(string);
   string=request.getParameter("g");
   double g1=Double.parseDouble(string);
   double area=getarea(s1, x1, g1);
   
   out.print("梯形的上底是"+s1+"下底是"+x1+"高是"+g1+"面积是"+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 + "/";
%>
<%!double r = (int) (Math.random() * 10) + 1;%>
<jsp:include page="circle.jsp">
    <jsp:param name="r" value="1" />
</jsp:include>
<br>
<jsp:include page="trapezoid.jsp">
    <jsp:param name="s" value="2" />
    <jsp:param name="x" value="3" />
    <jsp:param name="g" value="4" />
</jsp:include>
<!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>
</body>
</html>

 

3.任务三、详见Word图片

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%="top.jsp的文件内容包含在这里"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%="left.jsp的文件内容包含在这里"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%="right.jsp的文件内容包含在这里"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%="bottom.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>
  </head>
  <body >
  <table border="1" width="800" align="center" bgcolor="yellow">
  <tr align="center"><td colspan="2"><%@include file="top.jsp" %></td></tr>
  <tr align="center"><td><%@include file="left.jsp" %></td><td align="center"><%@include file="right.jsp" %></td></tr>
  <tr align="center"><td colspan="2"><%@include file="bottom.jsp" %></td></tr>
  </table>
   
  </body>
</html>

 

4.任务四、详见Word图片

 

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


</head>

<body>
    <%
    int a = (int) (Math.random() * 10 + 1);
  if(a%2==0){
     %>
    <jsp:forward page="two.jsp">
    <jsp:param value="<%=a %>" name="a"/>
    </jsp:forward>
    <%}
    else{ %>
      <jsp:forward page="one.jsp">
    <jsp:param value="<%=a %>" name="a"/>
    </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+"/";
%>


  
  <body>
    <%
     String a=request.getParameter("a");
    int a2=Integer.parseInt(a);
    out.print("我是生成的随机数:"+a2+",  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+"/";
%>



  </head>
  
  <body>
    <%
    String a=request.getParameter("a");
    int a1=Integer.parseInt(a);
    out.print("我是生成的随机数:"+a1+",  hello,我是奇数");
     %>
  </body>
</html>

 

posted @ 2022-04-03 15:10  XLKL  阅读(5)  评论(0编辑  收藏  举报