I am currently working on a JSP search component which uses sessions. The default session timeout is set at 30mins. In my JSP page I implement the following:
This exception is caught in an error page which states: "Session has Expired. Please start again".
The problem is when i test this page after 30mins I get a NullPointerException. After debugging I've found out that certain objects that I have placed in the session have disappeared. So I modified my code to do the following:
However, this does not solve the problem in that after 30mins I still get NullPointerException and not displaying "Session has expired". In the error page I catch IllegalStateException and print out the session expiry statement.
Can anyone tell me what other criteria I should look for when the session has expired?
Originally posted by Amin Mohammed-Coleman: I have tried null == session.getAttribute("userBean")...but for some reason it still throws a NullPointerException.
If your NullPointerException comes from that line, it probably means the session object is null, perhaps because you got it with getSession passing false[I] as argument. One way out of it is to check if [I]session is null.
Henrique Sousa<br />SCJP 1.4<br /> <br />All men die, not all men really live - Braveheart, 1995
Joined: Oct 18, 2004
Originally posted by Henrique Sousa:
Hi, ok...I'm at the point of tearing my hair out! I've basically tried the following scenarios:
if session == null if session.isRequestedSessionIdValid() !=true if session.getAttribute("object") ==null