Duke Martin wrote:

> I am working on a servlet that interacts with a database.  The servlet
> requies the user to login and upon request displays the users account info.
> How do I keep track of &/or store who is currently logged in?  How can I
> pass the login info between servlets?
>

Yoou can use HttpSession for this purpose. The server engine can maintain
session per user basis. Usage of this would be

The first time when request comes from user

1) HttpSession s = req.getSession(false);
2) If s is null the request has not been coming for the first time.
3) Ask the user to logon by sending login page
4) Authenticate the user
5) If valid user create a new session by
    HttpSession s = req.getSession(true);
6) Subsequent requests from user should contain the session ID
    i.e step 1 will return a valid value
7) You can also store user specific variables in a HttpSession Object
8) These variables are available across all the servlets.



Authr

==--==--==--==--==--==--==--==--==--==--==--==--==--==
S.Ramaswamy
Matrix Infotech Syndicate
D-7, Poorti, Vikaspuri, New Delhi, 110018, India
PHONE:    +91-11-5610050,   FAX: +91-11-5535103
WEB         http://MatrixInfotech.HyperMart.Net
==--==--==--==--==--==--==--==--==--==--==--==--==--==

___________________________________________________________________________
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