Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Vaadin session-timeout parameter

I am using Vaadin 7.1.7 and I can't figure out how to set session-timeout parameter (to, say, 1min).

As far as I can tell, Vaadin 7.x.x does not produce web.xml, it uses @VaadinServletConfiguration annotation but there doesn't seem to be a session-timeout parameter.

like image 497
user2981406 Avatar asked Nov 12 '13 01:11

user2981406


1 Answers

As far as I know there are 2 ways to set session-timeout in Vaadin 7.

In the web.xml:

<session-config>
    <session-timeout>1</session-timeout> <!-- 1 minute -->
</session-config>
<servlet>
    <servlet-name>MyServlet</servlet-name>
    <servlet-class>com.xyz.web.MyServlet</servlet-class>
    <init-param>
        <description>My Main Page</description>
        <param-name>UI</param-name>
        <param-value>com.xyz.web.MyUI</param-value>
    </init-param>
    <init-param>
        <description>Enable Session Timeout (heartbeat can't keep alive)</description>
        <param-name>closeIdleSessions</param-name>
        <param-value>true</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>MyServlet</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

Or we can set it programmatically (current session only):

VaadinSession.getCurrent().getSession().setMaxInactiveInterval(60); // 1 minute

It seems the servlet 3.0 annotations do not help: link

More help here: link

like image 151
Krayo Avatar answered Nov 07 '22 22:11

Krayo