Hi

You might also consider to allow multiple same-user logins ;-)...

restriction to only one login for each user brings more problems
than benefits.
(solutions posted here don't realy solve the problem -
there is no practical solution as long you can't distinguish
betwen "active" sessions and sessions no more used and waiting to timeout)

Most operating system, database, network or any other kind of "system"
writers came to this conclusion: everybody is happier if same user
is able to do multiple logins.
------------------------------------------------------------------

Otherwise you must implement a more sophisticated login servlet that:

- When id/pass pair is correct:
- Checks if same user is already logged in (by using a
  dictionary stored statically within login servlet or better in
  ServletContext where/if available)
- If the new logged in user already has opened session,
  asks him to choose betwen:
  a. continuing with login (and dropping out the already opened session)
  b. to quit logging in - and let the other session "alive".

You'll still be in trouble as users will start closing each other sessions.
Expect some fights  ending with flames on ... you!! :-)

Cezar.

 On Fri, 16 Apr 1999, Bruno Lowagie wrote:

> > In the init() method of my servlet I create a vector object.Whenever the
> > Agent logs in I check in the vector whether that agent id is there or not.
> > If it is not there then I put the Id into the vector ELSE I give a message
> > Agent already logged in.
>
> Why not store the login as key in a Hashtable with the SessionId as
> value. If some user logs in, you check if the sessionId that
> corresponds with his login still is a valid session.
> If not the user can login, otherwise you inform him of the fact
> that there is still an active session with his login...
>
> > This works fine if he uses the logoff option of my system BUT when the user
> > closes his browser the AgentID still remains in the vector and if he logs in
> > again it says "Agent already logged in" though he is not.
> >
> > How do I handle this event(closing of browser)???
> > I want to remove the Agent Id from the vector when the user closes his
> > browser.
>
> In most servers you can set a Timeout-value. For instance: if the
> user doesn't do anything for 30 minutes his session is invalidated
> automatically.
>
> This has nothing to do with your problem, but it could be
> a nice feature:
>
> In the application we are developing, we have an abstract servlet
> of which all our other servlets inherit. This abstract servlet
> has two static variables: a boolean shutdown and a String message.
> In a special HELPDESK-servlet. We can monitor all the current
> valid sessions (with getSessionContext). You can see who is logged
> in and from what IP-adress.
> We also show the number of minutes since the creation of the
> session and the last hit. You can see how every session times
> out after half an hour.
> If we plan to shutdown the server for maintenance, we set the
> static boolean shutdown = true and write something in the static
> String message. As soon as the boolean shutdown = true, the users
> can only do one more hit (for instance to submit the data they
> entered in a form), after that the abstract servlet invalidates
> their session and they are redirected to a login servlet that
> shows the message (for instance: the server wil be shutdown for
> maintenance. Please try again later).
>
> Servlets are great, don't you agree?
> --
> -------------------------------------------------------------------
> Bruno Lowagie           Academisch Rekencentrum Universiteit Gent
> Tel : 09/264.48.14      e-mail : [EMAIL PROTECTED]
> -------------------------------------------------------------------
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>


Cezar Totth                             email:  [EMAIL PROTECTED]
                                        Fax:    (401) 220 33 95
Genesys Software Romania                Phone:  (401) 638 49 44
Stefan Furtuna 169, sect.6
cod 77171, Bucharest
Romania

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to