• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Invalidating session on browser refresh

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All
I wanted to invalidate session on browser refresh...or on opening the same url on other tab of the browser

Whit i thought is to declare a static int in action class, and increment it every time the action class gets hit.
So if I refresh the browser, that static variable gets initialized to 0, so that if i keep a check on the variable for its value to be 0, i can actually invalidate the session.

something like this

static int ref = 0;

in processRequest of action class,
ref++;
if(ref == 1)
processRefresh(request);



public void processRefresh(HttpServletRequest request) {
HttpSession session = request.getSession(false);
if(session!=null) {
System.out.println(session);
System.out.println("session existing....and being invalidated in processor....");
session.invalidate();
}


But i'm getting some exceptions



If there is any other way, can someone help me out??

Thanks
Ravi
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

But i'm getting some exceptions


And they're secret, so you couldn't tell us what they are?

In any case, different browsers handle new tabs/windows differently: it's going to be tough to do this in any meaningful way without a fairly robust framework for handling session conversations (for example, like Seam does).
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic