日期:2014-05-17 浏览次数:20681 次
<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" errorPage="login.jsp"%> <% request.setCharacterEncoding("UTF-8"); String username = ""; int visitTimes = 0; Cookie[] cookies = request.getCookies(); for(int i=0; cookies!=null&&i<cookies.length;i++) { Cookie cookie = cookies[i]; if("username".equals(cookie.getName())) { username = cookie.getValue(); } else if("visitTimes".equals(cookie.getName())) { visitTimes = Integer.parseInt(cookie.getValue()); } } if(username == null || username.trim().equals("")) { throw new Exception("未登录,请先登录"); } Cookie visitTimesCookie =new Cookie("visitTimes", Integer.toString(++visitTimes)); response.addCookie(visitTimesCookie); %> <html> <head> </head> <body> <div align="center"> <fieldset> <legend>登录信息</legend> <form action="login.jsp" method="post"></form> <table> <tr> <td>你的帐号:</td> <td><%=username%></td> </tr> <tr> <td>登录次数</td> <td><%=visitTimes %></td> </tr> <tr> <td></td> <td> <input type="button" value="刷新" onclick="location=' <%= request.getRequestURI()%>?ts='+new Date().getTime();" class="button"> </td> </tr> </table> </fieldset> </div> </body> </html>