Home > Back-end >  Write a servlet to realize the function of statistics web site being visited
Write a servlet to realize the function of statistics web site being visited

Time:09-28

Implementation steps are as follows:

1) create a class ShowTimesServlet inheritance HttpServlet, rewrite the doGet and doPost method

2) in the doPost method call doGet method, in the doGet method can realize the function of statistics web site being visited, each time the user requests the Servlet, make visits times add 1

3) obtain the ServletContext, accessed through its function to remember the last time the number of times after (using the setAttribute () and the getAttribute () method)
  • Related