Using Deployment Descriptor:
Setting time-out at the deployment descriptor gives impact to the whole web-application. Looking at the example above, the session for the whole web application will terminate in 5 minutes (note: In deployment descriptor the time used for the timeout is measured in minutes)
Using setMaxInactiveInternal() :
HttpSession session = request.getSession() ;
session.setMaxInactiveInterval( 5 * 60) ;
The difference between using setMaxInactiveInterval() in a program and using
- setMaxInactiveInterval() method will only cause session time-out for a particular session instance and not the whole web-application.
- Other than that in setMaxInactiveInterval() method, time is measured in seconds not minutes. Take a look at the code above, to reach 5 minutes expiry (5*60) is used.
Author: Thiagu