首先写两个jsp文件
info.jsp
<body>
<%
HashMap<String, Integer> scoreMap = (HashMap<String, Integer>)application.getAttribute("scoreMap");
if(scoreMap == null){
scoreMap = new HashMap<String, Integer>();
}
String ip = request.getRemoteAddr();
Integer score = scoreMap.get(ip);
if (score == null) {
score = new Random().nextInt(7) - 1;
scoreMap.put(ip, score);
}
System.out.println(ip + ":" + score);
application.setAttribute("scoreMap",scoreMap);
request.setAttribute("score", score);
request.getRequestDispatcher("draw.jsp").forward(request, response);
%>
</body>
</html>
draw.jsp
<body>
<%
HashMap<String, Integer> scoreMap = (HashMap<String, Integer>) app