The Artima Developer Community
Sponsored Link

Java Answers Forum
Session Invalidation

1 reply on 1 page. Most recent reply: Mar 25, 2003 3:03 AM by sanjeev karanwal

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Anupama

Posts: 1
Nickname: javacity12
Registered: Mar, 2003

Session Invalidation Posted: Mar 23, 2003 12:47 AM
Reply to this message Reply
Advertisement
I am trying this functionality:

1.
On session timeout,whose value is set in web.xml,
if the session is invalid,throw an exception
and invalidate the session.
2.
If the user closes the brwoser directly,invalidate the session.

Here,I am not able to invaildate the session.Every time I open a new browser,taking the previous session.I guess

In case of
1.
I should redirect the exception page to another temp jsp which will invalidate the session.
2.
On form unLoad ,call a servlet which will invalidate the session.However once the sessionis invalidated,becomes null,throws a blank page.

Am I on the right track?Any code snippets,pointers ... will be helpful.

Code Snippet in the servlet:
/** To check whether the session already exists or not
* if the session does not exist,creating a new session
*
* if the session already exists,check whether it is valid or not
* if the session is already valid,do the normal processing
* else,throw an exception
*/
String forward;
HttpSession session = request.getSession();
System.out.println("session", session);
System.out.println("IdValid" + request.isRequestedSessionIdValid());
if ( null == session ) {
session = request.getSession(true);
Trace.data("Got a new one session", session);
/** do the usual processing
creation of the forward string
-----------------------------------
-----------------------------------
**/

} else {
//Trace.data("Session existing before the user logged in ", session);
if (request.isRequestedSessionIdValid()) {

/* If the session exists and is valid
use the same sesion
*/
Trace.checkpoint("Valid Session");
/** do the usual processing
creation of the forward string
-----------------------------------
-----------------------------------
**/

} else {
/* The session exists but is invalid
throw an exception
*/
Trace.checkpoint("Invalid Session");
Trace.checkpoint("Closing the Session");
// If I invalidate the sessionhere,it will become
//null,blank page
//session.invalidate();
//Throw Exception,forward string = error page

}
}

//Forward string created npw
Trace.data("forward : " , forward);
RequestDispatcher rd = getServletConfig().getServletContext().getRequestDispatcher(forward);
rd.forwar d(request, response);


sanjeev karanwal

Posts: 1
Nickname: sanju438
Registered: Mar, 2003

Re: Session Invalidation Posted: Mar 25, 2003 3:03 AM
Reply to this message Reply
Didn't get your problem exactly. What is the problem and what are you expecting.

Flat View: This topic has 1 reply on 1 page
Topic: Changing default colors in applet components Previous Topic   Next Topic Topic: Java text fields

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use