HTTPSESSIONLISTENER statistics Online number [转]

xiaoxiao2021-03-06  74

/ ** * Write the following sessioncounter.java * and compile SESSIONCOUNTER.CLASS * and then put it on the classpath of your website * sessioncount; import javax.servlet; import javax.servlet. *; Import Javax. Servlet.http. *;

Public class sessioncounter implements httpsessionListener {

Private static int activitynesss = 0;

Public void sessioncreated (httpsessionever "{activityations ;}

Public void sessionDestroyed (httpsessionever se) {if (agentismions> 0) Activeisms-;

Public static int getActdomesions;}} then established an online.jsp file to display online number <% @ Page Import = "sessioncount.sessioncounter"%> Online: <% = sessioncounter.getActiveSessionS ()%> then need The contents of the Web.xml file in your website is as follows: sessioncount.sessioncounter then restart your application server, access online.jsp check if The display is correct.

转载请注明原文地址:https://www.9cbs.com/read-120965.html

New Post(0)