aspose file tools*
The moose likes JSP and the fly likes Session Variables - Valid and otherwise Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Session Variables - Valid and otherwise" Watch "Session Variables - Valid and otherwise" New topic
Author

Session Variables - Valid and otherwise

George Larry
Ranch Hand

Joined: Nov 07, 2001
Posts: 52
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.
Pranit Saha
Ranch Hand

Joined: Sep 09, 2001
Posts: 130
Hi,
You can do like this..
if(session.getValue(" ")==null)
{
response.sendRedirect("logon.jsp");
}
Thanks
Pranit..
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
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
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
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

Joined: Nov 07, 2001
Posts: 52
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

Joined: Nov 07, 2001
Posts: 52
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.
 
subject: Session Variables - Valid and otherwise