top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How to restrict the no of user in the struts web applcation?

+5 votes
How to restrict the no of user in the struts web applcation?
posted Dec 13, 2013 by Prasad

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
Would you like to provide some more details...
@prasad: This is a very open question, will you be more precise to the question.

2 Answers

+2 votes
  1. Place the SessionID in the DB column against every session created by the user.
  2. This will provide count of the sessions currently active for the current user(s).
  3. Use a LoginServlet to check on the number of users having the active session (query the User_session table (from the DB) and check against the count.)

But in summary I agree this is a very open question and require more thoughts and inputs before answered precisely. Let me know if it serves the purpose.

answer Dec 13, 2013 by Naveena Garg
+1 vote

it is intended in a "container" way, this should go:

public class RequestFilter implements Filter
    private static final int THRESHOLD = 5;
    private static Map<String, AtomicInteger> accessMap = new HashMap<String, AtomicInteger>();

    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException
        HttpServletRequest request = (HttpServletRequest) servletRequest;

        AtomicInteger counter = accessMap.get(request.getRequestURI());
        if(counter == null) counter = new AtomicInteger();

        if(counter.incrementAndGet() < THRESHOLD)
            filterChain.doFilter(servletRequest, servletResponse);


    public void init(FilterConfig filterConfig) throws ServletException
        // nothing to do

    public void destroy()
        // nothing to do
answer Dec 14, 2013 by anonymous
Similar Questions
0 votes

I have a very minimal struts app I wrote some years ago. I want to upgrade it from 2.3 to 2.5. I'm wondering what requirements would allow the use of the essential dependencies jar. I am using only jstl tags, no struts tags. And my app is pretty simple.

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.