Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Automatic Session Expiry

 
sabeerdeenk kaderhussaindeen
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..
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?

login.jsp
=========
userId Text box
submit button


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

if(loginId.equals("abc"){
RequestDispatcher rd = request.getRequestDispatcher("Welcome.jsp");
} rd.forward(request, response);

web.xml
=======
<session-config>
<session-timeout>2</session-timeout>
</session-config>
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you considered using standard container managed security? It will give you the behaviour you want without needing to code it yourself.
 
sabeerdeenk kaderhussaindeen
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your reply... as a beginner i want to achieve this through code.. please help me!!
 
sabeerdeenk kaderhussaindeen
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i my self tried and got it!
 
sheetanshu krishna
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi sabeerdeenk kaderhussaindeen

To peform this operation programiticaly , we may also use the autorefresh feature of servlet
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic