JSP第三次作业
<body bgcolor=blue> <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="audio.jsp"/> </p> </body> </body>
<body bgcolor=pink> <embed src="english/english.mp3"autostart=false> 课文音频 </embed> </body>
2.任务二、教材P45 8题
<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>
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="5"/> </jsp:include> <br> <jsp:include page="ladder.jsp"> <jsp:param name="t" value="4"/> <jsp:param name="b" value="8"/> <jsp:param name="h" value="8"/> </jsp:include> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'index1.jsp' starting page</title> </head>
<body> <%!double getarea(double t,double b,double h){ double area=(t+b)*h/2; return area; } %> <% String string=request.getParameter("t"); double top=Double.parseDouble(string); string=request.getParameter("b"); double bottom=Double.parseDouble(string); string=request.getParameter("h"); double hight=Double.parseDouble(string); double area=getarea(top, bottom, hight); out.print("梯形的上底是"+top+"下底是"+bottom+"高是"+hight+"面积是"+area); %> </body>
3.任务三
<body> <table border="2" height="300" width="500" align="center" bgcolor="cyan"> <tr align="center"><td colspan="2"><%@include file="header.jsp" %></td></tr> <tr align="center"><td><%@include file="left.jsp" %></td><td align="center"> <%@include file="right.jsp" %></td></tr> <tr align="center"><td colspan="2"><%@include file="footer.jsp" %></td></tr> </table> </body>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%="我是header.jsp文件" %>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%="我是left.jsp文件" %>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%="我是right.jsp文件" %>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%="我是footer.jsp文件" %>
4.任务四
<body> <% String s=request.getParameter("number"); int a=Integer.parseInt(s); out.println("随机数是"+a); %> <h1>Hello,我是一个偶数!</h1> </body>
<body> <% String s=request.getParameter("number"); int a=Integer.parseInt(s); out.println("随机数是"+a); %> <h1>Hello,我是一个奇数!</h1> </body>
<body> <h1>产生一个0到10的随机整数</h1> <% int i= (int)Math.round(Math.random()*10); if(i%2==0){ %> <jsp:forward page="even.jsp"> <jsp:param value="<%=i %>" name="number"/> </jsp:forward> <% }else{ %> <jsp:forward page="oddNumber.jsp"> <jsp:param value="<%=i %>" name="number"/> </jsp:forward> <% } %> </body>