Vaadin 8 set session timeout












4















How to set timeout of a session in Vaadin 8?



I am not using web.xml, which has been the place to set it in prior versions of the framework.










share|improve this question





























    4















    How to set timeout of a session in Vaadin 8?



    I am not using web.xml, which has been the place to set it in prior versions of the framework.










    share|improve this question



























      4












      4








      4








      How to set timeout of a session in Vaadin 8?



      I am not using web.xml, which has been the place to set it in prior versions of the framework.










      share|improve this question
















      How to set timeout of a session in Vaadin 8?



      I am not using web.xml, which has been the place to set it in prior versions of the framework.







      java session vaadin vaadin8






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 20 '18 at 4:13









      Basil Bourque

      107k25368532




      107k25368532










      asked Feb 12 '18 at 7:59









      Stimpson CatStimpson Cat

      8631032




      8631032
























          2 Answers
          2






          active

          oldest

          votes


















          0














          tl;dr



          You can set the standard Servlet session’s timeout as a int number of whole seconds, after extracting from the wrapping VaadinSession.



          VaadinSession.getCurrent().getSession().setMaxInactiveInterval ( ( int ) TimeUnit.MINUTES.toSeconds( 30 ) ) ;


          Set session timeout programmatically



          Setting the session timeout is a feature in your web container, your Servlet engine, such as Tomcat, Jetty, etc. The Servlet spec defines this behavior for Java apps as part of its session handling.



          Vaadin wraps the Servlet session inside a VaadinSession. So extract the regular Servlet session from Vaadin as a WrappedSession, then call the setMaxInactiveInterval method to set the time to expire.



          Specify the time limit as a number of whole seconds. The TimeUnit enum is handy to calculate the seconds without resorting to “magic” numbers.



          VaadinSession               // Wraps a standard Servlet session.
          .getCurrent() // Access the current user’s session.
          .getSession() // Access the wrapped standard Servlet session.
          .setMaxInactiveInterval( // Set the timeout.
          ( int ) // Cast a `long` to an `int`.
          TimeUnit // The `TimeUnit` enum is more self-documenting than using a literal integer number.
          .MINUTES // Here we set a half hour, 30 minutes.
          .toSeconds( 30 ) // Set a number of whole seconds.
          )
          ;


          Here is a complete example Vaadin 8.5 app created from the Maven archetype vaadin-archetype-application. We added a single line to the beginning of the init method.



          package com.basilbourque.example;

          import javax.servlet.annotation.WebServlet;

          import com.vaadin.annotations.Theme;
          import com.vaadin.annotations.VaadinServletConfiguration;
          import com.vaadin.server.VaadinRequest;
          import com.vaadin.server.VaadinServlet;
          import com.vaadin.server.VaadinSession;
          import com.vaadin.ui.Button;
          import com.vaadin.ui.Label;
          import com.vaadin.ui.TextField;
          import com.vaadin.ui.UI;
          import com.vaadin.ui.VerticalLayout;

          import java.util.concurrent.TimeUnit;

          /**
          * This UI is the application entry point. A UI may either represent a browser window
          * (or tab) or some part of an HTML page where a Vaadin application is embedded.
          * <p>
          * The UI is initialized using {@link #init(VaadinRequest)}. This method is intended to be
          * overridden to add component to the user interface and initialize non-component functionality.
          */
          @Theme ( "mytheme" )
          public class MyUI extends UI {

          @Override
          protected void init ( VaadinRequest vaadinRequest ) {
          // Set Session timeout programmatically. Overrides the default timeout configured for Servlet.
          VaadinSession.getCurrent().getSession().setMaxInactiveInterval( ( int ) TimeUnit.MINUTES.toSeconds( 45 ) ); // Setting timeout of 45 minutes = ( 45 * 60 ) seconds.

          final VerticalLayout layout = new VerticalLayout();

          final TextField name = new TextField();
          name.setCaption( "Type your name here:" );

          Button button = new Button( "Click Me" );
          button.addClickListener( e -> {
          layout.addComponent( new Label( "Thanks " + name.getValue()
          + ", it works!" ) );
          } );

          layout.addComponents( name , button );

          setContent( layout );
          }

          @WebServlet ( urlPatterns = "/*",
          name = "MyUIServlet",
          asyncSupported = true )
          @VaadinServletConfiguration ( ui = MyUI.class,
          productionMode = false )
          public static class MyUIServlet extends VaadinServlet {
          }
          }


          Servlet, not Vaadin




          I am not using web.xml, which has been the place to set it in prior versions of the framework.




          Actually, the session timeout is a Servlet thing, not a Vaadin-specific thing. And the web.xml is a Servlet thing, not a Vaadin-specific thing.



          See:





          • javax.servlet.http.HttpSession::setMaxInactiveInterval(int interval) method


          • Servlet 3.1 specification (a PDF document)

          • Servlet 4 specification


          Further discussed in How to set session timeout dynamically in Java web applications?.






          share|improve this answer


























          • Thanks. I think 30 is still a magic number in your example, better use a constant SESSION_TIMEOUT_HALF_HOUR or anything like it. But nevertheless thanks!

            – Stimpson Cat
            Nov 21 '18 at 10:53



















          2














          Session timeout is set in web.xml.



          If you don't have one, then you will need to create one.



          How do i set session timeout in seconds in web.xml?



          As you seem to use spring boot, then this might apply to you



          Spring Boot Java Config Set Session Timeout






          share|improve this answer


























          • Where should this file be located? I am using spring boot

            – Stimpson Cat
            Feb 12 '18 at 8:25











          • That does not work. The session does not expire.

            – Stimpson Cat
            Feb 12 '18 at 9:43











          • @StimpsonCat Alternatively, you can programmatically set it by calling VaadinSession.getCurrent().getSession().setMaxInactiveInterval(numberOfSeconds); in your init method for example.

            – Morfic
            Feb 12 '18 at 9:43











          • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review

            – grizzthedj
            Feb 14 '18 at 14:07











          • @grizzthedj Agree for external links, but these are also stackoverflow posts. If the user had a more clear question, I could have marked it as duplicate of the spring boot stuff.

            – André Schild
            Feb 14 '18 at 15:14











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f48741820%2fvaadin-8-set-session-timeout%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          tl;dr



          You can set the standard Servlet session’s timeout as a int number of whole seconds, after extracting from the wrapping VaadinSession.



          VaadinSession.getCurrent().getSession().setMaxInactiveInterval ( ( int ) TimeUnit.MINUTES.toSeconds( 30 ) ) ;


          Set session timeout programmatically



          Setting the session timeout is a feature in your web container, your Servlet engine, such as Tomcat, Jetty, etc. The Servlet spec defines this behavior for Java apps as part of its session handling.



          Vaadin wraps the Servlet session inside a VaadinSession. So extract the regular Servlet session from Vaadin as a WrappedSession, then call the setMaxInactiveInterval method to set the time to expire.



          Specify the time limit as a number of whole seconds. The TimeUnit enum is handy to calculate the seconds without resorting to “magic” numbers.



          VaadinSession               // Wraps a standard Servlet session.
          .getCurrent() // Access the current user’s session.
          .getSession() // Access the wrapped standard Servlet session.
          .setMaxInactiveInterval( // Set the timeout.
          ( int ) // Cast a `long` to an `int`.
          TimeUnit // The `TimeUnit` enum is more self-documenting than using a literal integer number.
          .MINUTES // Here we set a half hour, 30 minutes.
          .toSeconds( 30 ) // Set a number of whole seconds.
          )
          ;


          Here is a complete example Vaadin 8.5 app created from the Maven archetype vaadin-archetype-application. We added a single line to the beginning of the init method.



          package com.basilbourque.example;

          import javax.servlet.annotation.WebServlet;

          import com.vaadin.annotations.Theme;
          import com.vaadin.annotations.VaadinServletConfiguration;
          import com.vaadin.server.VaadinRequest;
          import com.vaadin.server.VaadinServlet;
          import com.vaadin.server.VaadinSession;
          import com.vaadin.ui.Button;
          import com.vaadin.ui.Label;
          import com.vaadin.ui.TextField;
          import com.vaadin.ui.UI;
          import com.vaadin.ui.VerticalLayout;

          import java.util.concurrent.TimeUnit;

          /**
          * This UI is the application entry point. A UI may either represent a browser window
          * (or tab) or some part of an HTML page where a Vaadin application is embedded.
          * <p>
          * The UI is initialized using {@link #init(VaadinRequest)}. This method is intended to be
          * overridden to add component to the user interface and initialize non-component functionality.
          */
          @Theme ( "mytheme" )
          public class MyUI extends UI {

          @Override
          protected void init ( VaadinRequest vaadinRequest ) {
          // Set Session timeout programmatically. Overrides the default timeout configured for Servlet.
          VaadinSession.getCurrent().getSession().setMaxInactiveInterval( ( int ) TimeUnit.MINUTES.toSeconds( 45 ) ); // Setting timeout of 45 minutes = ( 45 * 60 ) seconds.

          final VerticalLayout layout = new VerticalLayout();

          final TextField name = new TextField();
          name.setCaption( "Type your name here:" );

          Button button = new Button( "Click Me" );
          button.addClickListener( e -> {
          layout.addComponent( new Label( "Thanks " + name.getValue()
          + ", it works!" ) );
          } );

          layout.addComponents( name , button );

          setContent( layout );
          }

          @WebServlet ( urlPatterns = "/*",
          name = "MyUIServlet",
          asyncSupported = true )
          @VaadinServletConfiguration ( ui = MyUI.class,
          productionMode = false )
          public static class MyUIServlet extends VaadinServlet {
          }
          }


          Servlet, not Vaadin




          I am not using web.xml, which has been the place to set it in prior versions of the framework.




          Actually, the session timeout is a Servlet thing, not a Vaadin-specific thing. And the web.xml is a Servlet thing, not a Vaadin-specific thing.



          See:





          • javax.servlet.http.HttpSession::setMaxInactiveInterval(int interval) method


          • Servlet 3.1 specification (a PDF document)

          • Servlet 4 specification


          Further discussed in How to set session timeout dynamically in Java web applications?.






          share|improve this answer


























          • Thanks. I think 30 is still a magic number in your example, better use a constant SESSION_TIMEOUT_HALF_HOUR or anything like it. But nevertheless thanks!

            – Stimpson Cat
            Nov 21 '18 at 10:53
















          0














          tl;dr



          You can set the standard Servlet session’s timeout as a int number of whole seconds, after extracting from the wrapping VaadinSession.



          VaadinSession.getCurrent().getSession().setMaxInactiveInterval ( ( int ) TimeUnit.MINUTES.toSeconds( 30 ) ) ;


          Set session timeout programmatically



          Setting the session timeout is a feature in your web container, your Servlet engine, such as Tomcat, Jetty, etc. The Servlet spec defines this behavior for Java apps as part of its session handling.



          Vaadin wraps the Servlet session inside a VaadinSession. So extract the regular Servlet session from Vaadin as a WrappedSession, then call the setMaxInactiveInterval method to set the time to expire.



          Specify the time limit as a number of whole seconds. The TimeUnit enum is handy to calculate the seconds without resorting to “magic” numbers.



          VaadinSession               // Wraps a standard Servlet session.
          .getCurrent() // Access the current user’s session.
          .getSession() // Access the wrapped standard Servlet session.
          .setMaxInactiveInterval( // Set the timeout.
          ( int ) // Cast a `long` to an `int`.
          TimeUnit // The `TimeUnit` enum is more self-documenting than using a literal integer number.
          .MINUTES // Here we set a half hour, 30 minutes.
          .toSeconds( 30 ) // Set a number of whole seconds.
          )
          ;


          Here is a complete example Vaadin 8.5 app created from the Maven archetype vaadin-archetype-application. We added a single line to the beginning of the init method.



          package com.basilbourque.example;

          import javax.servlet.annotation.WebServlet;

          import com.vaadin.annotations.Theme;
          import com.vaadin.annotations.VaadinServletConfiguration;
          import com.vaadin.server.VaadinRequest;
          import com.vaadin.server.VaadinServlet;
          import com.vaadin.server.VaadinSession;
          import com.vaadin.ui.Button;
          import com.vaadin.ui.Label;
          import com.vaadin.ui.TextField;
          import com.vaadin.ui.UI;
          import com.vaadin.ui.VerticalLayout;

          import java.util.concurrent.TimeUnit;

          /**
          * This UI is the application entry point. A UI may either represent a browser window
          * (or tab) or some part of an HTML page where a Vaadin application is embedded.
          * <p>
          * The UI is initialized using {@link #init(VaadinRequest)}. This method is intended to be
          * overridden to add component to the user interface and initialize non-component functionality.
          */
          @Theme ( "mytheme" )
          public class MyUI extends UI {

          @Override
          protected void init ( VaadinRequest vaadinRequest ) {
          // Set Session timeout programmatically. Overrides the default timeout configured for Servlet.
          VaadinSession.getCurrent().getSession().setMaxInactiveInterval( ( int ) TimeUnit.MINUTES.toSeconds( 45 ) ); // Setting timeout of 45 minutes = ( 45 * 60 ) seconds.

          final VerticalLayout layout = new VerticalLayout();

          final TextField name = new TextField();
          name.setCaption( "Type your name here:" );

          Button button = new Button( "Click Me" );
          button.addClickListener( e -> {
          layout.addComponent( new Label( "Thanks " + name.getValue()
          + ", it works!" ) );
          } );

          layout.addComponents( name , button );

          setContent( layout );
          }

          @WebServlet ( urlPatterns = "/*",
          name = "MyUIServlet",
          asyncSupported = true )
          @VaadinServletConfiguration ( ui = MyUI.class,
          productionMode = false )
          public static class MyUIServlet extends VaadinServlet {
          }
          }


          Servlet, not Vaadin




          I am not using web.xml, which has been the place to set it in prior versions of the framework.




          Actually, the session timeout is a Servlet thing, not a Vaadin-specific thing. And the web.xml is a Servlet thing, not a Vaadin-specific thing.



          See:





          • javax.servlet.http.HttpSession::setMaxInactiveInterval(int interval) method


          • Servlet 3.1 specification (a PDF document)

          • Servlet 4 specification


          Further discussed in How to set session timeout dynamically in Java web applications?.






          share|improve this answer


























          • Thanks. I think 30 is still a magic number in your example, better use a constant SESSION_TIMEOUT_HALF_HOUR or anything like it. But nevertheless thanks!

            – Stimpson Cat
            Nov 21 '18 at 10:53














          0












          0








          0







          tl;dr



          You can set the standard Servlet session’s timeout as a int number of whole seconds, after extracting from the wrapping VaadinSession.



          VaadinSession.getCurrent().getSession().setMaxInactiveInterval ( ( int ) TimeUnit.MINUTES.toSeconds( 30 ) ) ;


          Set session timeout programmatically



          Setting the session timeout is a feature in your web container, your Servlet engine, such as Tomcat, Jetty, etc. The Servlet spec defines this behavior for Java apps as part of its session handling.



          Vaadin wraps the Servlet session inside a VaadinSession. So extract the regular Servlet session from Vaadin as a WrappedSession, then call the setMaxInactiveInterval method to set the time to expire.



          Specify the time limit as a number of whole seconds. The TimeUnit enum is handy to calculate the seconds without resorting to “magic” numbers.



          VaadinSession               // Wraps a standard Servlet session.
          .getCurrent() // Access the current user’s session.
          .getSession() // Access the wrapped standard Servlet session.
          .setMaxInactiveInterval( // Set the timeout.
          ( int ) // Cast a `long` to an `int`.
          TimeUnit // The `TimeUnit` enum is more self-documenting than using a literal integer number.
          .MINUTES // Here we set a half hour, 30 minutes.
          .toSeconds( 30 ) // Set a number of whole seconds.
          )
          ;


          Here is a complete example Vaadin 8.5 app created from the Maven archetype vaadin-archetype-application. We added a single line to the beginning of the init method.



          package com.basilbourque.example;

          import javax.servlet.annotation.WebServlet;

          import com.vaadin.annotations.Theme;
          import com.vaadin.annotations.VaadinServletConfiguration;
          import com.vaadin.server.VaadinRequest;
          import com.vaadin.server.VaadinServlet;
          import com.vaadin.server.VaadinSession;
          import com.vaadin.ui.Button;
          import com.vaadin.ui.Label;
          import com.vaadin.ui.TextField;
          import com.vaadin.ui.UI;
          import com.vaadin.ui.VerticalLayout;

          import java.util.concurrent.TimeUnit;

          /**
          * This UI is the application entry point. A UI may either represent a browser window
          * (or tab) or some part of an HTML page where a Vaadin application is embedded.
          * <p>
          * The UI is initialized using {@link #init(VaadinRequest)}. This method is intended to be
          * overridden to add component to the user interface and initialize non-component functionality.
          */
          @Theme ( "mytheme" )
          public class MyUI extends UI {

          @Override
          protected void init ( VaadinRequest vaadinRequest ) {
          // Set Session timeout programmatically. Overrides the default timeout configured for Servlet.
          VaadinSession.getCurrent().getSession().setMaxInactiveInterval( ( int ) TimeUnit.MINUTES.toSeconds( 45 ) ); // Setting timeout of 45 minutes = ( 45 * 60 ) seconds.

          final VerticalLayout layout = new VerticalLayout();

          final TextField name = new TextField();
          name.setCaption( "Type your name here:" );

          Button button = new Button( "Click Me" );
          button.addClickListener( e -> {
          layout.addComponent( new Label( "Thanks " + name.getValue()
          + ", it works!" ) );
          } );

          layout.addComponents( name , button );

          setContent( layout );
          }

          @WebServlet ( urlPatterns = "/*",
          name = "MyUIServlet",
          asyncSupported = true )
          @VaadinServletConfiguration ( ui = MyUI.class,
          productionMode = false )
          public static class MyUIServlet extends VaadinServlet {
          }
          }


          Servlet, not Vaadin




          I am not using web.xml, which has been the place to set it in prior versions of the framework.




          Actually, the session timeout is a Servlet thing, not a Vaadin-specific thing. And the web.xml is a Servlet thing, not a Vaadin-specific thing.



          See:





          • javax.servlet.http.HttpSession::setMaxInactiveInterval(int interval) method


          • Servlet 3.1 specification (a PDF document)

          • Servlet 4 specification


          Further discussed in How to set session timeout dynamically in Java web applications?.






          share|improve this answer















          tl;dr



          You can set the standard Servlet session’s timeout as a int number of whole seconds, after extracting from the wrapping VaadinSession.



          VaadinSession.getCurrent().getSession().setMaxInactiveInterval ( ( int ) TimeUnit.MINUTES.toSeconds( 30 ) ) ;


          Set session timeout programmatically



          Setting the session timeout is a feature in your web container, your Servlet engine, such as Tomcat, Jetty, etc. The Servlet spec defines this behavior for Java apps as part of its session handling.



          Vaadin wraps the Servlet session inside a VaadinSession. So extract the regular Servlet session from Vaadin as a WrappedSession, then call the setMaxInactiveInterval method to set the time to expire.



          Specify the time limit as a number of whole seconds. The TimeUnit enum is handy to calculate the seconds without resorting to “magic” numbers.



          VaadinSession               // Wraps a standard Servlet session.
          .getCurrent() // Access the current user’s session.
          .getSession() // Access the wrapped standard Servlet session.
          .setMaxInactiveInterval( // Set the timeout.
          ( int ) // Cast a `long` to an `int`.
          TimeUnit // The `TimeUnit` enum is more self-documenting than using a literal integer number.
          .MINUTES // Here we set a half hour, 30 minutes.
          .toSeconds( 30 ) // Set a number of whole seconds.
          )
          ;


          Here is a complete example Vaadin 8.5 app created from the Maven archetype vaadin-archetype-application. We added a single line to the beginning of the init method.



          package com.basilbourque.example;

          import javax.servlet.annotation.WebServlet;

          import com.vaadin.annotations.Theme;
          import com.vaadin.annotations.VaadinServletConfiguration;
          import com.vaadin.server.VaadinRequest;
          import com.vaadin.server.VaadinServlet;
          import com.vaadin.server.VaadinSession;
          import com.vaadin.ui.Button;
          import com.vaadin.ui.Label;
          import com.vaadin.ui.TextField;
          import com.vaadin.ui.UI;
          import com.vaadin.ui.VerticalLayout;

          import java.util.concurrent.TimeUnit;

          /**
          * This UI is the application entry point. A UI may either represent a browser window
          * (or tab) or some part of an HTML page where a Vaadin application is embedded.
          * <p>
          * The UI is initialized using {@link #init(VaadinRequest)}. This method is intended to be
          * overridden to add component to the user interface and initialize non-component functionality.
          */
          @Theme ( "mytheme" )
          public class MyUI extends UI {

          @Override
          protected void init ( VaadinRequest vaadinRequest ) {
          // Set Session timeout programmatically. Overrides the default timeout configured for Servlet.
          VaadinSession.getCurrent().getSession().setMaxInactiveInterval( ( int ) TimeUnit.MINUTES.toSeconds( 45 ) ); // Setting timeout of 45 minutes = ( 45 * 60 ) seconds.

          final VerticalLayout layout = new VerticalLayout();

          final TextField name = new TextField();
          name.setCaption( "Type your name here:" );

          Button button = new Button( "Click Me" );
          button.addClickListener( e -> {
          layout.addComponent( new Label( "Thanks " + name.getValue()
          + ", it works!" ) );
          } );

          layout.addComponents( name , button );

          setContent( layout );
          }

          @WebServlet ( urlPatterns = "/*",
          name = "MyUIServlet",
          asyncSupported = true )
          @VaadinServletConfiguration ( ui = MyUI.class,
          productionMode = false )
          public static class MyUIServlet extends VaadinServlet {
          }
          }


          Servlet, not Vaadin




          I am not using web.xml, which has been the place to set it in prior versions of the framework.




          Actually, the session timeout is a Servlet thing, not a Vaadin-specific thing. And the web.xml is a Servlet thing, not a Vaadin-specific thing.



          See:





          • javax.servlet.http.HttpSession::setMaxInactiveInterval(int interval) method


          • Servlet 3.1 specification (a PDF document)

          • Servlet 4 specification


          Further discussed in How to set session timeout dynamically in Java web applications?.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 20 '18 at 4:24

























          answered Nov 20 '18 at 3:59









          Basil BourqueBasil Bourque

          107k25368532




          107k25368532













          • Thanks. I think 30 is still a magic number in your example, better use a constant SESSION_TIMEOUT_HALF_HOUR or anything like it. But nevertheless thanks!

            – Stimpson Cat
            Nov 21 '18 at 10:53



















          • Thanks. I think 30 is still a magic number in your example, better use a constant SESSION_TIMEOUT_HALF_HOUR or anything like it. But nevertheless thanks!

            – Stimpson Cat
            Nov 21 '18 at 10:53

















          Thanks. I think 30 is still a magic number in your example, better use a constant SESSION_TIMEOUT_HALF_HOUR or anything like it. But nevertheless thanks!

          – Stimpson Cat
          Nov 21 '18 at 10:53





          Thanks. I think 30 is still a magic number in your example, better use a constant SESSION_TIMEOUT_HALF_HOUR or anything like it. But nevertheless thanks!

          – Stimpson Cat
          Nov 21 '18 at 10:53













          2














          Session timeout is set in web.xml.



          If you don't have one, then you will need to create one.



          How do i set session timeout in seconds in web.xml?



          As you seem to use spring boot, then this might apply to you



          Spring Boot Java Config Set Session Timeout






          share|improve this answer


























          • Where should this file be located? I am using spring boot

            – Stimpson Cat
            Feb 12 '18 at 8:25











          • That does not work. The session does not expire.

            – Stimpson Cat
            Feb 12 '18 at 9:43











          • @StimpsonCat Alternatively, you can programmatically set it by calling VaadinSession.getCurrent().getSession().setMaxInactiveInterval(numberOfSeconds); in your init method for example.

            – Morfic
            Feb 12 '18 at 9:43











          • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review

            – grizzthedj
            Feb 14 '18 at 14:07











          • @grizzthedj Agree for external links, but these are also stackoverflow posts. If the user had a more clear question, I could have marked it as duplicate of the spring boot stuff.

            – André Schild
            Feb 14 '18 at 15:14
















          2














          Session timeout is set in web.xml.



          If you don't have one, then you will need to create one.



          How do i set session timeout in seconds in web.xml?



          As you seem to use spring boot, then this might apply to you



          Spring Boot Java Config Set Session Timeout






          share|improve this answer


























          • Where should this file be located? I am using spring boot

            – Stimpson Cat
            Feb 12 '18 at 8:25











          • That does not work. The session does not expire.

            – Stimpson Cat
            Feb 12 '18 at 9:43











          • @StimpsonCat Alternatively, you can programmatically set it by calling VaadinSession.getCurrent().getSession().setMaxInactiveInterval(numberOfSeconds); in your init method for example.

            – Morfic
            Feb 12 '18 at 9:43











          • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review

            – grizzthedj
            Feb 14 '18 at 14:07











          • @grizzthedj Agree for external links, but these are also stackoverflow posts. If the user had a more clear question, I could have marked it as duplicate of the spring boot stuff.

            – André Schild
            Feb 14 '18 at 15:14














          2












          2








          2







          Session timeout is set in web.xml.



          If you don't have one, then you will need to create one.



          How do i set session timeout in seconds in web.xml?



          As you seem to use spring boot, then this might apply to you



          Spring Boot Java Config Set Session Timeout






          share|improve this answer















          Session timeout is set in web.xml.



          If you don't have one, then you will need to create one.



          How do i set session timeout in seconds in web.xml?



          As you seem to use spring boot, then this might apply to you



          Spring Boot Java Config Set Session Timeout







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Feb 12 '18 at 8:56

























          answered Feb 12 '18 at 8:09









          André SchildAndré Schild

          3,71542136




          3,71542136













          • Where should this file be located? I am using spring boot

            – Stimpson Cat
            Feb 12 '18 at 8:25











          • That does not work. The session does not expire.

            – Stimpson Cat
            Feb 12 '18 at 9:43











          • @StimpsonCat Alternatively, you can programmatically set it by calling VaadinSession.getCurrent().getSession().setMaxInactiveInterval(numberOfSeconds); in your init method for example.

            – Morfic
            Feb 12 '18 at 9:43











          • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review

            – grizzthedj
            Feb 14 '18 at 14:07











          • @grizzthedj Agree for external links, but these are also stackoverflow posts. If the user had a more clear question, I could have marked it as duplicate of the spring boot stuff.

            – André Schild
            Feb 14 '18 at 15:14



















          • Where should this file be located? I am using spring boot

            – Stimpson Cat
            Feb 12 '18 at 8:25











          • That does not work. The session does not expire.

            – Stimpson Cat
            Feb 12 '18 at 9:43











          • @StimpsonCat Alternatively, you can programmatically set it by calling VaadinSession.getCurrent().getSession().setMaxInactiveInterval(numberOfSeconds); in your init method for example.

            – Morfic
            Feb 12 '18 at 9:43











          • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review

            – grizzthedj
            Feb 14 '18 at 14:07











          • @grizzthedj Agree for external links, but these are also stackoverflow posts. If the user had a more clear question, I could have marked it as duplicate of the spring boot stuff.

            – André Schild
            Feb 14 '18 at 15:14

















          Where should this file be located? I am using spring boot

          – Stimpson Cat
          Feb 12 '18 at 8:25





          Where should this file be located? I am using spring boot

          – Stimpson Cat
          Feb 12 '18 at 8:25













          That does not work. The session does not expire.

          – Stimpson Cat
          Feb 12 '18 at 9:43





          That does not work. The session does not expire.

          – Stimpson Cat
          Feb 12 '18 at 9:43













          @StimpsonCat Alternatively, you can programmatically set it by calling VaadinSession.getCurrent().getSession().setMaxInactiveInterval(numberOfSeconds); in your init method for example.

          – Morfic
          Feb 12 '18 at 9:43





          @StimpsonCat Alternatively, you can programmatically set it by calling VaadinSession.getCurrent().getSession().setMaxInactiveInterval(numberOfSeconds); in your init method for example.

          – Morfic
          Feb 12 '18 at 9:43













          While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review

          – grizzthedj
          Feb 14 '18 at 14:07





          While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review

          – grizzthedj
          Feb 14 '18 at 14:07













          @grizzthedj Agree for external links, but these are also stackoverflow posts. If the user had a more clear question, I could have marked it as duplicate of the spring boot stuff.

          – André Schild
          Feb 14 '18 at 15:14





          @grizzthedj Agree for external links, but these are also stackoverflow posts. If the user had a more clear question, I could have marked it as duplicate of the spring boot stuff.

          – André Schild
          Feb 14 '18 at 15:14


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f48741820%2fvaadin-8-set-session-timeout%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          How to fix TextFormField cause rebuild widget in Flutter

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith