JSP第五周作业

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

%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page contentType = "text/html"%>
<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"%>
<%@ page contentType = "text/html"%>

<!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 bgcolor=Thistle>
  <jsp:include page="circle.jsp">
  <jsp:param value="6" name="r"/>
  </jsp:include>
   <p>__________________</p>
   <jsp:include page="ladder.jsp">
   <jsp:param value="3" name="s"/>
   <jsp:param value="4" name="x"/>
   <jsp:param value="6" name="g"/>
   </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 r1=Double.parseDouble(r);
     double area=3.14*r1*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 s=request.getParameter("s");
   String x=request.getParameter("x");
   String g=request.getParameter("g");
   Double s1=Double.parseDouble(s);
   Double x1=Double.parseDouble(x);
   Double g1=Double.parseDouble(g);
   Double area=(s1+x1)*g1/2;
   out.print("梯形的上底是:"+s+"梯形的下底是:"+x+"梯形的高是:"+g+"梯形的面积:"+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>
  <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+"/";
%>
<%="main.jsp的文件内容包含在这里"%>
<%@ 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+"/";
%>
<%="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>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
  </head>
  
  <body>
   <%
        int i = (int) (Math.random() * 10 + 1);
        if (i % 2 == 0) {
    %>
    <jsp:forward page="even.jsp">
        <jsp:param value="<%=i %>" name="i" />
    </jsp:forward>
    <%
        } else {
    %>
    <jsp:forward page="odd.jsp">
        <jsp:param value="<%=i %>" name="i" />
    </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 'odd.jsp' starting page</title>
  </head>
  
  <body>
    <%
  String r=request.getParameter("i");
  int x=Integer.parseInt(r);
  out.print("随机数"+x); %><br>
  <fieldset>
   Hello,我是奇数!!!
  </fieldset>
 
  </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 'even.jsp' starting page</title>
  </head>
  
  <body>
    <%
  String r=request.getParameter("i");
  int x=Integer.parseInt(r);
  out.print("随机数"+x); %><br>
  <fieldset>
   Hello,我是偶数!!!
  </fieldset>
 
  </body>
</html>

 

posted @ 2022-04-03 19:06  F85  阅读(13)  评论(0编辑  收藏  举报