This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes how to  create always new session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to  create always new session" Watch "how to  create always new session" New topic
Author

how to create always new session

prasad kakani
Ranch Hand

Joined: Jul 15, 2008
Posts: 59
Can you please help me how to create always new session.
kranthi
Greenhorn

Joined: Dec 17, 2008
Posts: 10
Hi prasanth,

try like this to create a new session


HttpSession hs=request.getSession(true);
Integer i=(Integer)hs.getAttribute("ctrl");


Regards<br />kranthi
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

"SriLatha" please check your private messages for an important administrative matter. You can see them by clicking the My Private Messages link above.


SCJP, SCWCD.
|Asking Good Questions|
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Originally posted by SriLatha:
Hi prasanth,
try like this to create a new session
HttpSession hs=request.getSession(true);
Integer i=(Integer)hs.getAttribute("ctrl");


Note that request.getSession(true) doesn't always create a new session. It will only create a new session if one doesn't already exist. If one already exists then the old one will be used.

Question for Prasad: Why do you want to always make a new session? If you don't want the data to be shared between requests by the same user you should store the data in the Request scope rather than the Session scope.


Steve
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to create always new session