• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to create always new session

 
prasad kakani
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please help me how to create always new session.
 
kranthi
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi prasanth,

try like this to create a new session


HttpSession hs=request.getSession(true);
Integer i=(Integer)hs.getAttribute("ctrl");
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"SriLatha" please check your private messages for an important administrative matter. You can see them by clicking the My Private Messages link above.
 
Steve Luke
Bartender
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic