user means anyone who login to the application. We have a login page at first where one needs to enter username and password.
I just want to restrict the no. of users i.e. the one who provides username and password in order to access the application.
one simple way -- define an application level variable say - loggedInUserCount (of data type - int/Integer).
Increment this counter( loggedInUserCount ) when new user logs in.
Decrement this counter( loggedInUserCount ) when a user logs out.
If during login, it is found that loggedInUserCount has reached the maximum limit (10 as required in your application), you can deny user to login into application.
As already mentioned in earlier thread , make sure that your application has well defined entry (login) and exit (log out) points so that loggedInUserCount can be managed properly.
for example , apart from user deciding to get log out from application, user session can also get expire (if you have set it in your web.xml/servlet) leading to one of exit point of your application. So loggedInUserCount should be decreased in this scenario (session timeout).
So define your application entry and exit points and increment/decrement loggedInUserCount accordingly.
Make sure that you also consider multi-threading/concurrency scenarios.
Joined: Jun 24, 2005
Bear Bibeault wrote:What on Earth do connections have to do with tracking logins?
I did not mean database connection .. a login tracker object which release a entry pass to the user ..make sense ?
Each incoming request requires a thread for the duration of that request. If more simultaneous requests are received than can be handled by the currently available request processing threads, additional threads will be created up to the configured maximum (the value of the maxThreads attribute). If still more simultaneous requests are received, they are stacked up inside the server socket created by the Connector, up to the configured maximum (the value of the acceptCount attribute. Any further simultaneous requests will receive "connection refused" errors, until resources are available to process them.