第五周作业
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"%> <% 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>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>main2.jsp page</title> </head> <body> <table border="1" bgcolor="yellow"> <tr align="center"> <td colspan="2"><%@include file="top.jsp"%></td> </tr> <tr align="center"> <td><%@include file="left.jsp"%></td><td><%@include file="main.jsp"%></td> </tr> <tr align="center"> <td colspan="2"><%@include file="end.jsp"%></td> </tr> </table> </body> </html> 复制代码 复制代码 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <body> <%="main.jsp的文件内容包含在这里"%> </body> <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%="left.jsp的文件内容包含在这里 "%> <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%="top.jsp的文件内容包含在这里 "%> <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%="end.jsp的文件内容包含在这里 "%>
3.
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <body> <% double i=(int)(Math.random()*10)+1; if(i%2==0){ %> <jsp:forward page="oushu.jsp"> <jsp:param value="<%=i %>" name="number"/> </jsp:forward> <% } else{ %> <jsp:forward page="jishu.jsp"> <jsp:param value="<%=i %>" name="number"/> </jsp:forward> <% } %> </body> </html> 复制代码 复制代码 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <body> <% String s=request.getParameter("number"); out.print("随机数为:"+s);%> Hello,我是偶数!!! </body> </html> 复制代码 复制代码 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <body> <% String s=request.getParameter("number"); out.print("随机数为:"+s);%> Hello,我是奇数!!! </body> </html>