-
Notifications
You must be signed in to change notification settings - Fork 0
/
move.jsp
37 lines (32 loc) · 989 Bytes
/
move.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
session.setAttribute("attempt",session.getAttribute("attempt"));
int count=0;
if(session.getAttribute("attempt")==null){
count=0;
}
else{
count=(Integer)session.getAttribute("attempt");
}
Integer randomNumber=new Integer(new java.util.Random().nextInt(100));
Integer userNumber=Integer.parseInt(request.getParameter("user-guess"));
session.setAttribute("attempt",0);
session.setAttribute("userNumber",userNumber);
session.setAttribute("randomNumber",randomNumber);
if(randomNumber == userNumber){
session.setAttribute("attempt",count);
%>
<jsp:forward page="win.jsp" />
<%
count=0;
}
else{
count=count+1;
session.setAttribute("attempt",count);
%>
<jsp:forward page="loose.jsp" />
<%
}
session.setAttribute("attempt",count);
out.println(session.getAttribute("attempt"));
%>