I've created a Servlet that print out some data to the user. But before to print this "some data to the user", I put the logic that follows to manage when a session was expired.
Regarding the code below, I didn't understand why when the first if is reached a new session seems to be created. I'm saying that because when the page is redirected to expired.jsp, there is a new session there. But I didn't wrote any code to create a new session. (I'm using getSession(false)).