Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session Timeout Problem in Servlet and JSP

 
satyaprasad veeramsetti
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
I have developed simple web-application which contains session timeout using Filter. Please observe the following code.

1) I have created index.jsp as below,



2) I have created servlet as below,




3) I have created jsp as output as below,




4) I have created Filter as below,




5) web.xml file as below,







The actual problem of the above code is 'If one minute is complted, the session will be expired...., But it is not redirecting to index.jsp automatically'


Please help me.
 
Harry Jones
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure whether this will address your particular problem, but I had to exclude index.jsp from the test of the null session. Otherwise I created an infinite loop.
 
Rajkumar Angare
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Satya,

Set session time out value in web.xml, 1 = one minute, set the value as per your requirement.
 
Ayan mallick
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
first thing session-timeout means always max inactive interval/the time limit for which session is idle i.e no request is being made.

As fer as i know it automatically doesn't redirect you after session timeout limit.You have to make some request after specified time period in order to check whether session has been
invalidated or not.That time it will redirect you to login page.


If you want to check without making request apply HttpsessionListener concept.
check whether session is being destroyed or not.

please put chain.doFilter inside else block in order to avoid IllegalStateException.

Hope it helps you.
 
Himanshu bisht bebo
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think when the response is committed than the filter dofilter method is not called even after the session timeout so it not redirect it to index.jsp
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic