简体   繁体   中英

Redirecting to login when session timeout in JSF/Spring or automatic logout when session deactivate(or idel for a given time)

I have a J2EE application which uses JSF and Spring 3.x. My web app is developed in *.xhtml, and I have used JSF ManagedBeans. I want to redirect to login page when the session has elapsed the timeoout. I am bit new and need to know the following.

  1. How to set the session timeout time(Basically I want to set a maximum time where the application would be idle and redirect to the login page with an invalid session)
  2. What is the meta tag which I need to place in my *.xhtml which will direct to the login page?

Hope the requirement is clear. Just stating the requirements of my problem again

  1. System should not invalid the session as far as the user is interacting with the system.
  2. It Should only invalid the session and redirect to the login page when the system has been idle for a given time.

Tech Stack JSF with ManagedBeans(Have used face-config.xml etc..) Spring for the service layer Hibernate for the DAO layer and in defining the entities.

If by "idle" you mean not sending any request to the server then you have to set the session-timeout in your web.xml file. It should look like this for a 30 minutes timeout :

<session-config>
    <session-timeout>30</session-timeout>
</session-config>

To handle the redirection to login when the session timeout have a look at this answer .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM