• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Redirecting on session expired

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
Can anybody please let me know how can I achieve the below task
I want that if the user is idle for say 5 minutes it should be redirected to Log in page
I tried the following things but unable to achieve the result
1. I configured web.xml and added
<session-config>
<session-timeout>5</session-timeout>
</session-config>

I am able to make the session expire after 5 mins
But how can I make it automatically redirected to Login page.

Please let me know about that
Parvez
 
Ranch Hand
Posts: 35
Hibernate jQuery Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use request.isRequestedSessionIdValid()
 
parvez Moinuddin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rupesh Mhatre wrote:You can use request.isRequestedSessionIdValid()


@ Rupesh
Hi I tried that but still not working
Can you please elaborate on that
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

parvez Moinuddin wrote:But how can I make it automatically redirected to Login page.


You'll have to explain what you mean by this.

If you mean that, all by itself, the page should redirect when the session expires, well that's impossible. Without making any request back to the server, how would the browser know that the session has expired? Think about that.

Rather than relying on the session timeout, do you really need a client-side JavaScript timer?
 
Rupesh Mhatre
Ranch Hand
Posts: 35
Hibernate jQuery Eclipse IDE
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
request.isRequestedSessionIdValid() will give you boolean return if session is valid. As Bear Bibeault has already explained this can not happen automatically and you have to set JS timer for that nut using this atleast you can take care that if user is on the same page till timeout happens and try making new request it will redirect user to your session expire page for this you have to place your code inside the if block having this check condition.
reply
    Bookmark Topic Watch Topic
  • New Topic