karthick prabhu
karthick prabhu

Reputation: 433

How to track user session in struts 2

I am using struts 2 with mysql. Using jsp for presentation.In my application i have three users , admin,tester,BA .For example if a admin user logged in then i will show him the adminindex.jsp page, i have done the coding in my action class to return to corresponding userindex pages.What i want is now to show the logged in user in adminindex.jsp and also need to implement the logout functionality. Kindly guide or provide me any good tutorial links.

The user should be logged out after few minutes if there is no activity.

thanks in advance

Upvotes: 1

Views: 1440

Answers (1)

mana
mana

Reputation: 6547

The auto-logout comes for free. The session has a timeout. If the user idles for too long, the session will be terminated automatically. The default value for tomcat is 30 min.

Also see here: What is the default session timeout for a Java EE website?

If you need to implement further logout functionality, simply kill the users session by calling:

request.getSession().invalidate();

maybe build our own logout.action in struts2.

cheers, mana

Upvotes: 2

Related Questions