It's not a secret anymore!*
The moose likes Servlets and the fly likes Is it possible to create more than one HttpSession in our Application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Is it possible to create more than one HttpSession in our Application" Watch "Is it possible to create more than one HttpSession in our Application" New topic
Author

Is it possible to create more than one HttpSession in our Application

PavanPL KalyanK
Ranch Hand

Joined: Feb 28, 2009
Posts: 212

What will happen if i

HttpSession sess1 = request.getSession(true);

HttpSession sess2 = request.getSession(true);

Will the Container will create two sessions for a Thread Request??
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Have you checked what HttpSession#getId() says?
Have you read the HttpSession API doc at any way?

http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpSession.html
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


Each request can be assigned only to one session !!
So the second call to request.getSession(true); will actually return the same session created in the first statement.
PavanPL KalyanK
Ranch Hand

Joined: Feb 28, 2009
Posts: 212
Thanks Balu Sadhasivam ,
 
wood burning stoves
 
subject: Is it possible to create more than one HttpSession in our Application