Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

session.invalidate()

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

//User clicks SWITCH IDENTITY, we are require to abandon
// existing session & switch to new login user
// Code snipplets below
HttpSession session = request.getSession();
if (session != null)
session.invalidate(); // destroy everything on session
// We then require a Total new session
session = request.getSession(true);
In Jrun3, The session above returns the old session which
will throw exception if we call
session.putValue ("Name", "XX");
Anyone can suggest how I can access a new session
 
thilak subbiah
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have tested the following code in servletrunner and it is working properly.Destroys the session and creates a new session.
//code
HttpSession session = req.getSession(true);
session.invalidate();
session = req.getSession(true);
session.putValue("Hello","Test");
regards,
Thilak.V

Originally posted by kuaikuai:

//User clicks SWITCH IDENTITY, we are require to abandon
// existing session & switch to new login user
// Code snipplets below
HttpSession session = request.getSession();
if (session != null)
session.invalidate(); // destroy everything on session
// We then require a Total new session
session = request.getSession(true);
In Jrun3, The session above returns the old session which
will throw exception if we call
session.putValue ("Name", "XX");
Anyone can suggest how I can access a new session

 
Amond Adams
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Session can be loosely defined as a connection (connection-less connection as HTTPServlets are HTTP centric) thus renewal or establishing a new session should invlove server and client ports to recommunicate and restablish a connection-less connection (TCP based). Now when the old session is invalidated and a new one is REQUESTED, there could not be an immediate response where that is also dependent upon network status, etc.... So could it be that you need to check if the new session has established before you can do something with it, like naming it. etc..
Any Comments........
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai Adams,
can you explain me what is connection-less-connection and HTTP centric connection?is there any other types of connections possible?
yours
balraj
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic