File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Managing Session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Managing Session" Watch "Managing Session" New topic

Managing Session

AshishcKumar singh

Joined: Dec 16, 2008
Posts: 9
Hi all!

I am making a discussion forums site. I want to track user's using session object.
I am creating session as follows:-

String Username=request.getParameter("textuname");

i am retrieving the value when required.

Doubt m having is that if on 'logout' by any user if i invalidate the session using session.invalidate(); wont it destroy sessions of all other users online???

What i need is tat only session of that particular user is destroyed and all others who are online can keep continuing with their tasks.

Ben Souther

Joined: Dec 11, 2004
Posts: 13410

No, each user has their own session.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
AshishcKumar singh

Joined: Dec 16, 2008
Posts: 9
Hi thanks for replying..

You mean there'll be automatic handling of each user's session??

Please explain me this:--

i am giving the session's name as "userid". On each user's pc..there'l a temporary cookie created by this session object named "userid" or what??..

How is it going to work?can you please explain me all this?..

Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

I don't understand that. You said
i am giving the session's name as "userid"

But in your original post you showed an example of putting an attribute named "userid" into a session.

Here's what you need to know: the container will maintain a session for each user. You don't really need to know how it does that. Whether it uses cookies or URL-rewriting or ventricles, you don't care. You can have a session for each user.
AshishcKumar singh

Joined: Dec 16, 2008
Posts: 9
Thanks man..
I agree. Here's the link:
subject: Managing Session
It's not a secret anymore!