日期:2014-05-18 浏览次数:20840 次
public class CountServlet extends HttpServlet {
public void service(
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
HttpSession session = request.getSession();
Integer count = (Integer) session.getAttribute("count");
if(count == null){
count = 1;
}else{
count++;
}
session.setAttribute("count", count);
out.println("你是第 " + count + " 次访问");
out.close();
}
}