第五周作业
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> </head> <body bgcolor=cyan> <br>英文课文(Enlish 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"%> <% 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> </head> <body bgcolor=pink> <embed src="english/english.mp3"autostat=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> </head> <body> <jsp:include page="circle.jsp"> <jsp:param value="4" name="r"/> </jsp:include> <jsp:include page="ladder.jsp"> <jsp:param value="4" name="a"/> <jsp:param value="6" name="b"/> <jsp:param value="2" name="c"/> </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> </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> </head> <body> <% String a=request.getParameter("a"); String b=request.getParameter("b"); String c=request.getParameter("c"); double sd=Double.parseDouble(a); double xd=Double.parseDouble(b); double g=Double.parseDouble(c); double area=(sd+xd)*g/2; out.print(area); %> </body> </html>
3.任务三、详见Word图片
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <html> <head> <title>My JSP 'end.jsp' starting page</title> <style type="text/css"> div{ border:1px solid red; display: inline; } #d1{ width: 400px; } #d2{ width: 200px; } #d3{ width: 200px; } #d4{ width: 400px; } </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="utf-8"%> <html> <head> <title>My JSP 'end.jsp' starting page</title> </head> <body> This is end.jsp. <br> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <html> <head> <title>My JSP 'end.jsp' starting page</title> </head> <body> This is left.jsp. <br> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <html> <head> <title>My JSP 'end.jsp' starting page</title> </head> <body> This is main.jsp. <br> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <html> <head> <title>My JSP 'end.jsp' starting page</title> </head> <body> This is top.jsp. <br> </body> </html>
4.任务四、详见Word图片
1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 <% 3 String path = request.getContextPath(); 4 String basePath = request.getScheme() + "://" 5 + request.getServerName() + ":" + request.getServerPort() 6 + path + "/"; 7 %> 8 9 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 10 <html> 11 <head> 12 <base href="<%=basePath%>"> 13 14 <title>My JSP 'odd.jsp' starting page</title> 15 16 <meta http-equiv="pragma" content="no-cache"> 17 <meta http-equiv="cache-control" content="no-cache"> 18 <meta http-equiv="expires" content="0"> 19 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> 20 <meta http-equiv="description" content="This is my page"> 21 <!-- 22 <link rel="stylesheet" type="text/css" href="styles.css"> 23 --> 24 25 </head> 26 <%--奇数 --%> 27 <body> 28 <% 29 String odd = request.getParameter("i"); 30 int j = Integer.parseInt(odd); 31 out.print("随机数" + j); 32 %> 33 是奇数!!! 34 </body> 35 </html>
1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 <% 3 String path = request.getContextPath(); 4 String basePath = request.getScheme() + "://" 5 + request.getServerName() + ":" + request.getServerPort() 6 + path + "/"; 7 %> 8 9 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 10 <html> 11 <head> 12 <base href="<%=basePath%>"> 13 14 <title>My JSP 'even.jsp' starting page</title> 15 16 <meta http-equiv="pragma" content="no-cache"> 17 <meta http-equiv="cache-control" content="no-cache"> 18 <meta http-equiv="expires" content="0"> 19 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> 20 <meta http-equiv="description" content="This is my page"> 21 <!-- 22 <link rel="stylesheet" type="text/css" href="styles.css"> 23 --> 24 <%--偶数 --%> 25 </head> 26 27 <body> 28 <% 29 String even = request.getParameter("i"); 30 int ou = Integer.parseInt(even); 31 out.print("随机数" + ou); 32 %> 33 是偶数!!! 34 35 </body> 36 </html>
复制代码 1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 <% 3 String path = request.getContextPath(); 4 String basePath = request.getScheme() + "://" 5 + request.getServerName() + ":" + request.getServerPort() 6 + path + "/"; 7 %> 8 9 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 10 <html> 11 <head> 12 <base href="<%=basePath%>"> 13 14 <title>My JSP 'example2.jsp' starting page</title> 15 16 <meta http-equiv="pragma" content="no-cache"> 17 <meta http-equiv="cache-control" content="no-cache"> 18 <meta http-equiv="expires" content="0"> 19 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> 20 <meta http-equiv="description" content="This is my page"> 21 <!-- 22 <link rel="stylesheet" type="text/css" href="styles.css"> 23 --> 24 25 </head> 26 27 <body> 28 <h1>生成[]0,10]之间的随机数</h1> 29 <% 30 int i = (int) (Math.random() * 10) + 1; 31 if (i % 2 == 0) { 32 %> 33 <jsp:forward page="even.jsp"> 34 <jsp:param value="<%=i %>" name="i" /> 35 </jsp:forward> 36 <% 37 } else { 38 %> 39 <jsp:forward page="odd.jsp"> 40 <jsp:param value="<%=i%>" name="i" /> 41 </jsp:forward> 42 <% 43 } 44 %> 45 </body> 46 </html>