つまり、数字の更新に問題があります。最初の数字が 8 と 13 で、誰かが 21 を送信した場合、次に誰かがページをロードしたときに、数字は 13 と 21 になります。何だかわからない
<%@ page import="java.io.*"%><%@
import="java.util.*"%><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>MAIN</title>
</head>
<body>
<%
String sum = (String) session.getAttribute("sum");
if (sum==null) {
sum = "0";
session.setAttribute("sum",sum);
}
int isum = Integer.parseInt(sum);
String fib1= (String) session.getAttribute("fib1");
fib1 = "8";
session.setAttribute("fib1",fib1);
int ifib1 = Integer.parseInt(fib1);
String fib2= (String) session.getAttribute("fib2");
fib2 = "13";
int ifib2 = Integer.parseInt(fib2);
isum=ifib1+ifib2;
boolean numberReceived=false;
int usum = -1;
try{
usum=Integer.parseInt(request.getParameter("number"));
numberReceived=true;
}catch(NumberFormatException nfe){
System.out.print("error");
}
if (!numberReceived) {
out.print("You need to enter a value");
} else {
if (usum==isum) {
out.print("correct");
ifib1+=5;
} else {
out.print("incorrect");
}
}
session.setAttribute("fib1",""+ifib1);
%>
<input type="button" value="go" onclick="doTheGObutton();">
<form action="index.jsp" method="post">
<%=fib1%> + <%=fib2%> = <input type="text" name="number">
<input type="submit" value="continue" name="submit">
</form>
</body>
</html>