Reputation: 855
I'm writing my first GWT application and i'm at the point of implementing sessions.
Currently i' generating a
HttpServletRequest request = getThreadLocalRequest();
HttpSession httpSession = request.getSession(true);
httpSession.setMaxInactiveInterval(1000 * 60 * 2);//2min
and then verifying that the session is the same as the users via RPC call to server before displaying any screen
HttpServletRequest request = getThreadLocalRequest();
HttpSession httpSession = request.getSession(false);
if(user.getSessionId().equals(result.getSessionId()))
//display screen
My question is concerning setMaxInactiveInterval(); the inactive timeout doesn't seem to work for me at all - the session doesnt expire on its own after two mins
Am i going about it the right way? Thanks.
p.s. i used this as a jump off: http://snipt.net/javagner/session-in-gwt/
Upvotes: 1
Views: 862
Reputation: 9
httpSession.setMaxInactiveInterval(1000 * 60 * 2);//2min
This is not 2 minutes, but rather 2000 minutes.
https://docs.oracle.com/javaee/6/api/index.html?javax/servlet/http/HttpSession.html
javax.servlet.http.HttpSession.setMaxInactiveInterval(int interval)
Specifies the time, in seconds, between client requests before the servlet container will invalidate this session.
Upvotes: 1
Reputation: 2997
Usually there is this in the web.xml
<session-config>
<session-timeout>30</session-timeout> <!-- 30 minutes -->
</session-config>
Upvotes: 1