1,编写一个JSP页面,统计网页被访问次数
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>显示访问记录</title>
</head>
<%
Integer count = (Integer)application.getAttribute("count");
if(count != null){
count = 1 + count;
}else{
count = 1;
}
application.setAttribute("count",count);
%>
<body>
<form name="loginForm" method="post" action="showCount.jsp">
用户名:<input type="text" name="userName" />
密码:<input type="password" name="pwd" />
<input type="submit" value="登录">
</form>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
Integer i = (Integer)application.getAttribute("count");
out.println("您好,您是第 " + i +" 位访问本网站的用户" );
%>
2,