pinga123 said:
Hi guys,
How would i configure my application server(TOMCAT) to only allow 10 concurrent sessions at a time.
For every connection after that there should be a proper message indicating maximum sessiions reached.
maxThreads will limit the maximum number of active connections to the value you specify; acceptCount will be the additional buffer. But this doesn't mean it will limit to 10 sessions only, this is only to configure tomcat to handle these many requests at a single time slice.
There are two ways u can limit the max. active session, either you use a Servlet Filter (more generic) or a Controller Servlet with a variable in the application scope to hold the current no. of active sessions. Both ways u can redirect to an alert page to show the desired message. Filters will take some time to figure out, a controller servlet will be much easier to implement .. for this simply do the following :
(i) check for
session.isNew() in calling JSP, if true then set an attribute with a value to identify this in the servlet
(ii) define a private static integer variable for the controller servlet to hold the current active sessions, initialize to 0
(ii) in doPost() or doGet(), check the value of the session variable; if it matches new session then check if the above variable is <10; if true then increment and carry on, else simply redirect to your error page.
This method is not limited to applications servers, but the application itself. Also limiting the total active http connection doesn't mean limiting the no. of sessions .