Arvind
Arvind

Reputation: 6474

how to set session timeout programatically in a gwt based java web app

I am working on a java web app which uses Smart GWT for the front end, in this app Oauth is used for initial authentication- when a user is successfully authenticated, a token is obtained which contains token expiry time period in seconds.

What I want to do is, pass this expiry time period to my Java code via RPC, and in the server side code set the session timeout to this time period.

There is one question which deals with session timeout, however the solutions mentioned there require use of Servlet/JSP- how do I set the session timeout from server side Java code in a GWT based java web app?

Upvotes: 2

Views: 3230

Answers (1)

Marcelo
Marcelo

Reputation: 4608

Any GWT RPC Servlet that you have has to extend the standard Java Servlet class (see the RemoteServiceServlet docs) - so any method that you know of that works on standard Java Servlets will also work on your server-side Java code.

For instance, this:

HttpServletRequest request = this.getThreadLocalRequest();
HttpSession session = request.getSession();
session.setMaxInactiveInterval(20*60);

will set the timeout to 20 minutes.

Upvotes: 2

Related Questions