一、实验目的
- 掌握eclipse开发工具的使用;
- jsp标记、如指令标记,动作标记;
- 变量和方法的声明;
- Java程序片;
实验:看电影
源代码watchMovie.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body bgcolor = cyan>
<%
request.setCharacterEncoding("gb2312");
String backMoneyStr = request.getParameter("number");
String mess = request.getParameter("mess");
int backMoney= 0;
int count = 0;
int coin= 5;
backMoney =Integer.parseInt(backMoneyStr);
while(true){
count ++;
if(count * coin>backMoney)
break;
}
backMoney = backMoney- (count- 1) * coin;
mess=mess+ "<br>找赎”+ (count-1) +”张面值" + coin+"元的钱币";
if (backMoney> 0) {
%> <jsp:forward page = "change2. jsp" >
<jsp:param name= "number" value= "<%=backMoney %>" />
<jsp:param name= "mess" value= "<%=mess %>" />
</jsp:forward >
<% }
else{
out.print("<br>" + mess);
%>
<br><embed src = " movie/movie. mp4" width- 300 height = 270
autostart = false >
看电影
</embed>
<% } %>
</body>
</html>
change5.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body bgcolor = cyan>
<% request.setCharacterEncoding("gb2312");
String backMoneyStr = request.getParameter("number");
String mess = request.getParameter("mess");
int backMoney = 0;
int count = 0;
int coin = 5;
backMoney = Integer.parseInt(backMoneyStr);
while(true){
count ++;
if(count * coin > backMoney)
break;
}
backMoney = backMoney - (count - 1) * coin;
mess = mess + "<br>找赎" + (count - 1) + "张面值" + coin + "元的钱币";
if(backMoney > 0){
%>
<jsp:forward page="change2.jsp">
<jsp:param name="number" value="<%=backMoney %>"/>
<jsp:param name="mess" value="<%=mess %>"/>
</jsp:forward>
<% }
else{
out.print("<br>"+mess);
%> <br><embed src="movie/movie.mp4" width=300 height=270 autostart="false">
看电影
</embed>
<% } %>
</body>
</html>
Change2.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body bgcolor = cyan>
<% request.setCharacterEncoding("gb2312");
String backMoneyStr = request.getParameter("number");
String mess = request.getParameter("mess");
int backMoney = 0;
int count = 0;
int coin = 2;
backMoney = Integer.parseInt(backMoneyStr);
while(true){
count ++;
if(count * coin > backMoney)
break;
}
backMoney = backMoney - (count - 1) * coin;
mess = mess + "<br>找赎" + (count - 1) + "张面值" + coin + "元的钱币";
if(backMoney > 0){
%>
<jsp:forward page="change1.jsp">
<jsp:param name="number" value="<%=backMoney %>"/>
<jsp:param name="mess" value="<%=mess %>"/>
</jsp:forward>
<% }
else{
out.print("<br>"+mess);
%> <br><embed src="movie/movie.mp4" width=300 height=270 autostart="false">
看电影
</embed>
<% } %>
</body>
</html>
Change1.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body bgcolor = cyan>
<% request.setCharacterEncoding("gb2312");
String backMoneyStr = request.getParameter("number");
String mess = request.getParameter("mess");
int backMoney = 0;
int count = 0;
int coin = 1;
backMoney = Integer.parseInt(backMoneyStr);
while(true){
count ++;
if(count * coin > backMoney)
break;
}
backMoney = backMoney - (count - 1) * coin;
mess = mess + "<br>找赎" + (count - 1) + "张面值" + coin + "元的钱币";
out.print("<br>" + mess);
%>
<br><embed src="movie/movie.mp4" width=300 height=270 autostart="false">
看电影
</embed>
</body>
</html>
实验三角形
源代码
sjx.jsp
<%@ page language="java" contentType="text/html; utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body bgcolor = cyan>
<% double a= 6.12,b = 7.08,c = 9.22;
%>
<p style= "font-family:宋体;font-size:36">
<br>加载triangle.jsp计算三边为<%= a %>,<%= b %>,<%= c %>的三角形面积。
<jsp:include page = "myfile/triangle.jsp">
<jsp:param name = "sideA" value = "<%= a %>"/>
<jsp:param name = "sideB" value = "<%= b %>"/>
<jsp:param name = "sideC" value = "<%= c %>"/>
</jsp:include>
</p>
</body>
</body>
</html>
Triangle.jsp
<%@ page language="java" contentType="text/html; utf-8"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body bgcolor = cyan>
<% double a= 6.12,b = 7.08,c = 9.22;
%>
<p style= "font-family:宋体;font-size:36">
<br>加载triangle.jsp计算三边为<%= a %>,<%= b %>,<%= c %>的三角形面积。
<jsp:include page = "myfile/triangle.jsp">
<jsp:param name = "sideA" value = "<%= a %>"/>
<jsp:param name = "sideB" value = "<%= b %>"/>
<jsp:param name = "sideC" value = "<%= c %>"/>
</jsp:include>
</p>
</body>
</body>
</html>