my dog learned polymorphism*
The moose likes Servlets and the fly likes session timeout implementation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "session timeout implementation" Watch "session timeout implementation" New topic
Author

session timeout implementation

naveen putrevu
Greenhorn

Joined: Sep 09, 2007
Posts: 22
Hi,

I am using struts2 for my webapp development. I am also using "MyFilterDispatcher.java" to process all incoming requests.

My requirement is: when a user doesn't access any part of the application for 2 mins; then redirect the user to login page. I've used <session-timeout>2</session-timeout> in web.xml. In addition to this, How do i redirect the user to login.jsp page now?


Thanks.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

naveen putrevu wrote:when a user doesn't access any part of the application for 2 mins; then redirect the user to login page.


when user send request, check the user session. if it is invalid then, redirect to the login page
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 684


Hi,

As you are using struts2 so make one Interceptor like loginInterceptro which check your user session available or not ....

If user session not available with application just redirect to login page.

That login interceptor configure with Strut.xml file with your application and put that tag to every page with login required.




Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
naveen putrevu
Greenhorn

Joined: Sep 09, 2007
Posts: 22
@Nishan

I am already using an interceptor which extends "FilterDispatcher" by the way. The code goes something like this...

public void doFilter(ServletRequest req, ServletResponse res,
FilterChain chain) throws IOException, ServletException {

super.doFilter(req, res, chain);

}


Here, how do I check whether the user session is available or not?
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 684


Hi,


At the time of Login make one session object like user and check this user session at login interceptor.

I think this will help you ....

http://www.vitarara.org/cms/struts_2_cookbook/creating_a_login_interceptor



 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: session timeout implementation
 
Similar Threads
Session Management
session Problem.
Checking to see if a session has expired
Handling session timeout and session invalidate differently
How to handle a session timeout exception (with MVP Places and Activities) ?