Because there is no way for an HTTP client to signal that it no longer needs a session, each session has an associated timeout so that its resources can be reclaimed. The timeout period can be accessed by using a session’s [get|set]MaxInactiveInterval methods.
You can also set the timeout period in the deployment descriptor using NetBeans IDE:
Open the web.xml file in the web.xml editor.
Click General at the top of the editor.
Enter an integer value in the Session Timeout field. The integer value represents the number of minutes of inactivity that must pass before the session times out.
To ensure that an active session is not timed out, you should periodically access the session by using service methods because this resets the session’s time-to-live counter.