internet chat application


Web tier: servlets, JSP, Web frameworks: internet chat application

  1. internet chat application (4 messages)


    I have developed a java-chat application running on tomcat and it is working fine. Now I want to modify it such that it allows only two users access it at any time. If the third user logs in(even with valid username and password), he should not be allowed to enter the chat.

    I know that I can get the number of users who have logged in by incrementing a counter in the service method(every time when a user accesses the servlet, the counter will be incremented in the service method). But how to keep track in a servlet when the user has left a chat from the servlet.


    Threaded Messages (4)

  2. internet chat application[ Go to top ]

    You can maintain a counter in a session, so that every time a user invokes the servlet, the counter increments, which can be limited to <3(as in your case). As the user leaves the chat, the session counter ends. Hope this will solve your problem.
  3. internet chat application[ Go to top ]

      can you pass code to me?Thanks
  4. internet chat application[ Go to top ]

    Stick the counter in an application scope session variable, that will do it.

    Check out the set methods in HttpSession for how to do it.

    Won't necessarily work in a cluster unless the sessions are replicated across the cluster.

    Also, can't remember if the session object is synchronized or not, so make sure you synch correctly to avoid a race condition.


  5. internet chat application[ Go to top ]

    hai anand,
    can u please tell me how
    u developed the char app in the
    i am developing a chat app
    which should support 2000 clients.
    the chat client is an applet.
    how to write a chat servlet for
    that.will be roubust if i use
    the applet servlet communication?
    will the servlets push the data
    to client applet running behind
    the help me.