Is the HTTP Session maintained even when the network connection goes down? Can the same browser instance resume a previous session after re-establishing the network connection?

Michael Dean

In the Servlets API, HttpSessions are implemented as objects in memory on the web app server. Therefore, the session will be maintained on ther server as long as the server is running (or until it "times out" after the max inactive interval has passed). Even if the server "goes offline" and then "goes online," the session will be maintained if the web app server process is still running (and the session has not timed out).

Session cookies are sent to the browser to allow the browser to identify itself to the server, thereby allowing the server to "look up" the user's session. The session cookies are deleted when the browser process exits, so if the user "goes offline" and then "goes online" and makes a request, the session cookie will still be available--assuming the same browser process. However, even if the cookie is available and sent to the server, if the session has timed out, the session is not available (the user would get a new session with a call to request.getSession()).

Note that different browsers maintain session cookies across multiple browser windows in different ways. See Re: About session for more information.