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>
    <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"></jsp:include>
  <br>课文音频(English Audio):</br>
  <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>
    <title>My JSP 'index.jsp' starting page</title>
  </head>
  
  <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"%>

<!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="5" name="r"/>
</jsp:include>
<p>--------分割线--------</p>
<jsp:include page="ladder.jsp">
<jsp:param value="5" name="sd"/>
<jsp:param value="8" name="xd"/>
<jsp:param value="8" name="h"/>
</jsp:include>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

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

  </head>
  
  <body>
我是被加载的求圆形面积界面
<%
String r=request.getParameter("r");
double b=Double.parseDouble(r);
double area=3.14*b*b;
out.print(area);
 %>
  </body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  
    <title>My JSP 'ladder.jsp' starting page</title>

  </head>
  
  <body>
我是被加载的求梯形面积界面
<%
String sd=request.getParameter("sd");
String xd=request.getParameter("xd");
String h=request.getParameter("h");
double s=Double.parseDouble(sd);
double x=Double.parseDouble(xd);
double H=Double.parseDouble(h);
double area=(s+x)*H/2;
out.print(area);
 %>
  </body>
</html>

 

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>
    <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+"/";
%>
<%="main.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、

 

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

 

posted @ 2022-04-02 15:37  小Q爱吃巧克力  阅读(48)  评论(0编辑  收藏  举报