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><body bgcolor=cyan> <br> 英文课文(English Text): <p style="font- family:宋体;font-size:18;color:black"> <jsp:include page="english/english.txt"/> <br>课文音频(English Audio):<br> <jsp:include page ="MyJsp2.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><body bgcolor=pink> <embed src="english/english.mp3"autostart=false type="application/octet-stream"> 课文音频<embed></body> </html>
2.任务二、教材P45 8题
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body bgcolor=cyan>
<p style="font-family: 宋体; font-size: 36">
<jsp:include page="circle.jsp">
<jsp:param name="r" value=" 3" />
</jsp:include>
<p style="font-family: 宋体; font-size: 36">
<jsp:include page="ladder.jsp">
<jsp:param name="shang" value="2" />
<jsp:param name="xia" value=" 4" />
<jsp:param name="gao" value="2" />
</jsp:include>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Insert title here</title> </head> <body> 我是被加载的求圆形面积页面 <% String r = request.getParameter("r"); double r1 = Double.parseDouble(r); double area = 3.14 * r1 * r1; out.print(area); %> </body> </html>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Insert title here</title> </head> <body> 我是被加载求梯形面积的页面 <% String shang = request.getParameter("shang"); String xia = request.getParameter("xia"); String gao = request.getParameter("gao"); double shang1 = Double.parseDouble(shang); double xia1 = Double.parseDouble(xia); double gao1 = Double.parseDouble(gao); double area = (shang1 + xia1) * gao1 / 2; out.print(area); %> </body> </html>
任务三、详见Word图片
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Insert title here</title> <style type="text/css"> td{ /* margin: auto; */ width: 200px; text-align:center; background: yellow; } tr{ width:400px; height:50px; } td,tr,table{ border: 1px solid red; } </style> </head> <body> <table> <tr> <td id="top" colspan="2"><jsp:include page="top.jsp"></jsp:include></td> </tr> <tr> <td id="left"><jsp:include page="left.jsp"></jsp:include></td> <td id="main"><jsp:include page="main.jsp"></jsp:include></td> </tr> <tr> <td id="end" colspan="2"><jsp:include page="end.jsp"></jsp:include></td> </tr> </table> </body> </html>
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
top.jsp文件
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
left.jsp文件
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
main.jsp文件
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
end.jsp文件
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 <!DOCTYPE HTML> 3 <html> 4 <head> 5 <meta charset="utf-8"> 6 <title>My JSP 'index.jsp' starting page</title> 7 </head> 8 <body> 9 <% 10 int i = (int) (Math.random() * 10 + 1); 11 if (i % 2 == 0) { 12 %> 13 <jsp:forward page="ou.jsp"> 14 <jsp:param value="<%=i %>" name="num" /> 15 </jsp:forward> 16 <% 17 } else { 18 %> 19 <jsp:forward page="ji.jsp"> 20 <jsp:param value="<%=i %>" name="num" /> 21 </jsp:forward> 22 <% 23 } 24 %> 25 </body> 26 </html>
1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 <!DOCTYPE HTML> 3 <html> 4 <head> 5 <meta charset="utf-8"> 6 <title>My JSP 'index.jsp' starting page</title> 7 </head> 8 <body> 9 <% 10 String m = request.getParameter("num"); 11 int n = Integer.parseInt(m); 12 out.print("随机数为" + n + "<br>"); 13 %> 14 Hello,我是一个奇数! 15 </body> 16 </html>
1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 2 <!DOCTYPE HTML> 3 <html> 4 <head> 5 <meta charset="utf-8"> 6 <title>My JSP 'index.jsp' starting page</title> 7 </head> 8 <body> 9 <% 10 String m = request.getParameter("num"); 11 int n = Integer.parseInt(m); 12 out.print("随机数为" + n + "<br>"); 13 %> 14 Hello,我是一个偶数! 15 </body> 16 </html>