JSP第三次作业

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

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
  <head>
  </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="index.jsp"/>
   </p>
  </body>
</html>
   </p>
  </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=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+"/";
%>
 <%!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"%>
<%
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>
    <%!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 'index1.jsp' starting page</title>
  </head>
  <body>
     <%!double getarea(double a,double b,double c){
           double area=(a+b)*c/2;
           return area;
   } %>
   <%
   String string=request.getParameter("a");
   double s1=Double.parseDouble(string);
   string=request.getParameter("b");
   double x1=Double.parseDouble(string);
   string=request.getParameter("c");
   double g1=Double.parseDouble(string);
   double area=getarea(s1, x1, g1);
   
   out.print("梯形的上底是"+s1+"下底是"+x1+"高是"+g1+"面积是"+area);
    %>
   
  </body>
</html>

 

 

 

 3.任务三、详见Word图片 表格

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>表格</title>
</head>
<body>
<table border="1">
    <tr align="center">
        <td colspan="2"><%@include file="top.jsp"%></td>
    </tr>
    <tr align="center">
        <td><%@include file="left.jsp"%></td><td><%@include file="right.jsp"%></td>
    </tr>
    <tr align="center">
        <td colspan="2"><%@include file="bottom.jsp"%></td>
    </tr>
</table>
</body>
</html>

 

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>top</title>
</head>
<body>
<%=
"top.jsp的文件内容包含在这里"
%>
</body>
</html>

 

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>left</title>
</head>
<body>
<%=
"left.jsp的文件内容包含在这里"
%>
</body>
</html>

 

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>right</title>
</head>
<body>
<%=
"right.jsp的文件内容包含在这里"
%>
</body>
</html>

 

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>bottom</title>
</head>
<body>
<%=
"bottom.jsp的文件内容包含在这里"
%>
</body>
</html>

 

 

 4.任务四、详见Word图片

<%@page import="java.util.Random"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
    int a = new Random().nextInt(11);
if(a/2==0){%>
    <jsp:forward page="number1.jsp"></jsp:forward>
<%}else{%>
    <jsp:forward page="number2.jsp"></jsp:forward>
<%}
%>
</body>
</html>

 

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body>
偶数
</body>
</html>

 

<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body>
奇数
</body>
</html>

 

 

posted @ 2022-04-03 15:47  崔宝元  阅读(30)  评论(0编辑  收藏  举报