• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Session Variables - Valid and otherwise

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd like to create a session for my web page that expires after 15-20 minutes- then, once expired, have the user forwarded to the login page.
I think I've got the timing thing down...
session.setMaxInactiveInterval( x );
The part I don't know how to do is check for the invalid session and do the forward. I haven't found any way to tell if the session.isInactive();
Here's what I'd like to do:

There is no isInactive() function... that I know of. How can this be done?
Thank you.
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
You can do like this..
if(session.getValue(" ")==null)
{
response.sendRedirect("logon.jsp");
}
Thanks
Pranit..
 
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alternatively, you can use the standard authentication mechanism and set the sessions to timeout (at the application level) after X minutes. Users will then automatically be returned to the login page when they try to access a protected resource.
Simon
 
Simon Brown
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or if you don't want to use the standard authentication mechanisn, you could use a filter (from Servlets 2.3) to wrap up this logic for you. This saves you putting it on every page.
Simon
 
George Larry
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm... I tried that, but I'm getting an IllegalStateException.
Here's what I've done (in my header.jsp file):

Any ideas?
 
George Larry
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the standard authentication mechanism and where can I learn how to use it?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic