page1.jpg:
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<html>
<head>
<title></title>
</head> <body>
<img src="data:images/xxx.png" height="300">
<p>猜电影票价格</p>
<%
session.setAttribute("number",49);
%>
<form action="page2.jsp" method="post">
<input type="text" name="guess"/>
<input type="submit" value="guess"/>
</form>
</body>
</html>
page2.jsp:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<html>
<head>
<title>guess</title>
</head>
<body>
<%
Integer str1=(Integer)session.getAttribute("number");
String str2=request.getParameter("guess");
int num1=Integer.valueOf(str1);
int num2=Integer.parseInt(str2);
if(num1==num2){
out.print("您猜对了");
}else if(num1>num2){
out.print("您猜小了---<a href='page1.jsp'>guess</a>");
}else{
out.print("您猜大了---<a href='page1.jsp'>guess</a>");
}
%>
</body>
</html>