%@ page import="javax.servlet.http.*" %> <%@ include file="sudoku-data.jsp" %> <%! String sessionid; String puzzle=""; String puzzleid; String submitted; String duration; String soln = ""; String s=""; String HTMLtitle; String Level; String PreviousDate; String d2; String Replay; int puzzlenum; int j = 0; Cookie[] cookies; Cookie chocChip; String CookieName; int CookieValue; int lasteasy = 0; int lastmedium = 0; int lasthard = 0; int num; int num2; String IntToString(int i) { Integer ii = new Integer( i ); return ii.toString(); } int StringToInt(String s) { return (int)Integer.parseInt(s); } /** * gks get a random integer depending on the value of * L - which is the name of a cookie, I think. * gks changed this to have response in the call. * @param response Http Response * @param L a cookie name (may be null; if so, default to 'e') * @return (?What??) */ int GetRandom(HttpServletResponse response, String L) { // gks guard against no cookie if ( L == null ){ L = "e"; } if (L.equals("e")) {num = nume;num2 = lasteasy;} if (L.equals("m")) {num = numm;num2 = lastmedium;} if (L.equals("h")) {num = numh;num2 = lasthard;} if (num2 > -1) { if (num2 < num - 1) { ++num2; chocChip = new Cookie(L, IntToString(num2)); chocChip.setMaxAge(365 * 24 * 60 * 60); response.addCookie(chocChip); return num2; } else { chocChip = new Cookie(L, "0"); chocChip.setMaxAge(365 * 24 * 60 * 60); response.addCookie(chocChip); return 1; } } else { double d = Math.random(); d = d * (double)num; j = 0; while (j < d) ++j; if (j == 0) ++j; if (L.equals("e")) { chocChip = new Cookie(L, e[--j][0]); chocChip.setMaxAge(365 * 24 * 60 * 60); response.addCookie(chocChip); } if (L.equals("m")) { chocChip = new Cookie(L, m[--j][0]); chocChip.setMaxAge(365 * 24 * 60 * 60); response.addCookie(chocChip); } if (L.equals("h")) { chocChip = new Cookie(L, h[--j][0]); chocChip.setMaxAge(365 * 24 * 60 * 60); response.addCookie(chocChip); } return j; } } %>
<% cookies = request.getCookies(); for (int u=0;u


