1.编写一个jsp页面,产生0-9的随机数作为用户的幸运数字,将其保存在会话中,并重定向到另一个jsp中,在该页面中将数字显示出来
<%@ page import="java.util.Random" %><%--
Created by IntelliJ IDEA.
User: Administrator
Date: 2019/7/15 0015
Time: 15:43
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<%
Random random=new Random();//建立随机数对象
int i=random.nextInt(10);//确定范围0-9
session.setAttribute("num",i);//把变量i放置到session内,key为"num"
response.sendRedirect("index4.jsp");//重定向到index4.jsp
%>
<%=i%>
</body>
</html>
2.完成网站访问量统计
<%@ page import="java.util.concurrent.CountDownLatch" %><%--
Crea