JSP第五周作业
第一题
<html><body bgcolor="#8a2be2"> <br>英文课文(English Text):</br> <p style="font-family: 宋体;font-size: 18px;color: black"> <jsp:include page="english/english.txt"/> <br>课文音频(English Audio):</br> <jsp:include page="audio.jsp"/> </p> </body> </html>
<html><body bgcolor="#8a2be2">
<embed src="english/english.mp3" autostart="false">
课文音频
</embed>
</body></html>
第二题
<body> <% String r = request.getParameter("r"); double bj = Double.parseDouble(r); double area = 3.14 * bj * bj; out.print("圆形的面积是"+area); %> </body>
<body> <% String s = request.getParameter("s"); double high = Double.parseDouble(s); String x = request.getParameter("x"); double xia = Double.parseDouble(x); String g = request.getParameter("g"); double gao = Double.parseDouble(g); double area = (high + xia) * gao / 2.0; out.print("梯形的面积是:"+area); %> </body>
<body> <jsp:include page="circle.jsp"> <jsp:param value="5" name="r" /> </jsp:include> <br> <jsp:include page="ladder.jsp"> <jsp:param value="3" name="s" /> <jsp:param value="4" name="x" /> <jsp:param value="5" name="g" /></jsp:include> </body>
第三题
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<style type="text/css">
div{
border:1px solid red;
display: inline;
}
#d1{
width: 1000px;
height:100px;
}
#d2{
width: 500px;
height:100px;
}
#d3{
width: 500px;
height:100px;
}
#d4{
width: 1000px;
height:100px;
}
</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>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <%="main.jsp的文件内容包含在这里 "%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <%="top.jsp的文件内容包含在这里 "%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <%="end.jsp的文件内容包含在这里 "%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <%="left.jsp的文件内容包含在这里 "%>
第四题
<body> <% int i = (int) (Math.random() * 10 + 1); if (i % 2 == 0) { %> <jsp:forward page="two.jsp"> <jsp:param value="<%=i %>" name="num" /> </jsp:forward> <% } else { %> <jsp:forward page="one.jsp"> <jsp:param value="<%=i %>" name="num" /> </jsp:forward> <% } %> </body>
<body> <% String m = request.getParameter("num"); int n = Integer.parseInt(m); out.print("随机数为" + n + "<br>"); %> Hello,我是一个偶数! </body>