aspose file tools*
The moose likes Servlets and the fly likes creating two different session objects in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "creating two different session objects in java" Watch "creating two different session objects in java" New topic
Author

creating two different session objects in java

rammie singh
Ranch Hand

Joined: Mar 26, 2009
Posts: 116
hi every body...

i wanted to create two different session objects . How is it possible??

what i tried was..



here the output i get is..

s1 is ... Peter
session object are equal (true/false)..true


even i am accesing "s1" with session2 object

what i want is session2 to be a different object which should give [b]"null"[b] on accesing variable [b]"s1"[b]

can any one help me how can i acheive that??
Rituraj Jain
Ranch Hand

Joined: Nov 28, 2008
Posts: 37
hi rammie,

Can you specify what is the need of doing so.

by calling methods request.getSession() or request.getSession(true);

in both cases it will return a existing session Object but if there is no existing session it will create new one for you.

if you calls request.getSession(false), it will return session object if there is already created session but it will return null if no existing session is there

in any case ony one session will be maintained not two.....


Rituraj Jain
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Why do you believe you want to create two sessions? There's only one session associated with a request.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: creating two different session objects in java