File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
creating two different session objects in java
Joined: Mar 26, 2009
Oct 26, 2009 04:56:49
hi every body...
i wanted to create two different session objects . How is it possible??
what i tried was..
String test = "Peter"; HttpSession session1 = request.getSession(); HttpSession session2 = request.getSession(); session1.setAttribute("s1", test); System.out.println("s1 is ... "+session2.getAttribute("s1")); System.out.println("session object are equal (true/false).."+session1.equals(session2));
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??
Joined: Nov 28, 2008
Oct 26, 2009 05:17:29
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.....
Joined: Sep 29, 2008
Oct 26, 2009 06:03:51
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:
subject: creating two different session objects in java
Session object within two servlets and jsp in the single application
Problem with a select tag
Why Session objects are different?
Session Related Question
Accesing two synchronized methods
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013