wood burning stoves 2.0*
The moose likes Servlets and the fly likes Automatic Session Expiry Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Automatic Session Expiry" Watch "Automatic Session Expiry" New topic

Automatic Session Expiry

sabeerdeenk kaderhussaindeen

Joined: Oct 29, 2010
Posts: 3
login.jsp --> MyServlet --> WelcomePage.jsp

i want to make the session time out when i keep WelcomePage.jsp for more than 2 minutes,
and control has to come to login.jsp what code i have to write in welcome.jsp to achieve this?

userId Text box
submit button

String loginId = request.getParameter("userId");
HttpSession session = null;
session = request.getSession(true);
session.setAttribute("LoginId", loginId);

RequestDispatcher rd = request.getRequestDispatcher("Welcome.jsp");
} rd.forward(request, response);

Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Have you considered using standard container managed security? It will give you the behaviour you want without needing to code it yourself.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
sabeerdeenk kaderhussaindeen

Joined: Oct 29, 2010
Posts: 3
thanks for your reply... as a beginner i want to achieve this through code.. please help me!!
sabeerdeenk kaderhussaindeen

Joined: Oct 29, 2010
Posts: 3
i my self tried and got it!
sheetanshu krishna

Joined: Jun 06, 2008
Posts: 5

Hi sabeerdeenk kaderhussaindeen

To peform this operation programiticaly , we may also use the autorefresh feature of servlet
Don't get me started about those stupid light bulbs.
subject: Automatic Session Expiry
Similar Threads
Session timeout in struts
Doubt in Session Time out.
what is session expunging?was asked this question in an interview?
Setting session timeout dynamically in Java code
Error: Requested resourse() not available