SESSION VARIABLE BECOMES NULL AFTER SOME REFRESH
Hi, I have a jsp page which is refreshed atuomatically every 10 seconds.I get and put values in the session by using the implicit session variable . Everything works fine for say 2-3 mins after that the session becomes null and throws a null pointer exception. IN the try block I even have a code as try { if (session == null || session.isNew()) { //do something } else { //do otherwise } }catch(Exception e ) { //print stack trace and value of session } I get a null pointer exception and session is preinted as null but even the if block is noit executed . I printed the value of request.getSession(false);.This gives me session object ,where as the implicit session does not have this after many refresh interval . During the first few refresh both have the same value. Also note that this runs fine in Windows ,I get this problem only in UNIX . I use tomcat 3.2 in unix and view using IE in windows Please help me out as to where I am going wrong . thanks and Regards Mukund
RE: SESSION VARIABLE BECOMES NULL AFTER SOME REFRESH
Hi There, The NPE is coming from the { if (session == null || session.isNew()) } since even if session is null then you are still trying to call a method of session. a safer alternative would be if (session == null) { //error } else { if (session.isNew()) { } else { } } Thanks Pete -Original Message- From: MUKUND Premchander [mailto:[EMAIL PROTECTED] Sent: 12 April 2004 11:19 To: [EMAIL PROTECTED] Subject: SESSION VARIABLE BECOMES NULL AFTER SOME REFRESH Hi, I have a jsp page which is refreshed atuomatically every 10 seconds.I get and put values in the session by using the implicit session variable . Everything works fine for say 2-3 mins after that the session becomes null and throws a null pointer exception. IN the try block I even have a code as try { if (session == null || session.isNew()) { //do something } else { //do otherwise } }catch(Exception e ) { //print stack trace and value of session } I get a null pointer exception and session is preinted as null but even the if block is noit executed . I printed the value of request.getSession(false);.This gives me session object ,where as the implicit session does not have this after many refresh interval . During the first few refresh both have the same value. Also note that this runs fine in Windows ,I get this problem only in UNIX . I use tomcat 3.2 in unix and view using IE in windows Please help me out as to where I am going wrong . thanks and Regards Mukund - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: SESSION VARIABLE BECOMES NULL AFTER SOME REFRESH
Hi , Thank you for your reply . Guess I did not put my qn the right way . In the code block if (session == null || session.isNew() I do not access any session variables Actually I just redirect the page. I am unable to understand why the implicit session variable becomes null suddenly after some refresh and why this occurs only when tomcat runs in UNIX .I don't get this problem in Windows Thanks and Regards Mukund -Original Message- From: Peter Guyatt [mailto:[EMAIL PROTECTED] Sent: Monday, April 12, 2004 4:10 PM To: Tomcat Users List Subject: RE: SESSION VARIABLE BECOMES NULL AFTER SOME REFRESH Hi There, The NPE is coming from the { if (session == null || session.isNew()) } since even if session is null then you are still trying to call a method of session. a safer alternative would be if (session == null) { //error } else { if (session.isNew()) { } else { } } Thanks Pete -Original Message- From: MUKUND Premchander [mailto:[EMAIL PROTECTED] Sent: 12 April 2004 11:19 To: [EMAIL PROTECTED] Subject: SESSION VARIABLE BECOMES NULL AFTER SOME REFRESH Hi, I have a jsp page which is refreshed atuomatically every 10 seconds.I get and put values in the session by using the implicit session variable . Everything works fine for say 2-3 mins after that the session becomes null and throws a null pointer exception. IN the try block I even have a code as try { if (session == null || session.isNew()) { //do something } else { //do otherwise } }catch(Exception e ) { //print stack trace and value of session } I get a null pointer exception and session is preinted as null but even the if block is noit executed . I printed the value of request.getSession(false);.This gives me session object ,where as the implicit session does not have this after many refresh interval . During the first few refresh both have the same value. Also note that this runs fine in Windows ,I get this problem only in UNIX . I use tomcat 3.2 in unix and view using IE in windows Please help me out as to where I am going wrong . thanks and Regards Mukund - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: SESSION VARIABLE BECOMES NULL AFTER SOME REFRESH
Peter Guyatt wrote: Hi There, The NPE is coming from the { if (session == null || session.isNew()) } since even if session is null then you are still trying to call a method of session. According to Java language specification, 15.24 Conditional-Or Operator ||, it's not so. That says that right-hand operator only executes when left-hand operator is false, so in this code session!=null. -Original Message- From: MUKUND Premchander [mailto:[EMAIL PROTECTED] Sent: 12 April 2004 11:19 To: [EMAIL PROTECTED] Subject: SESSION VARIABLE BECOMES NULL AFTER SOME REFRESH Hi, I have a jsp page which is refreshed atuomatically every 10 seconds.I get and put values in the session by using the implicit session variable . Everything works fine for say 2-3 mins after that the session becomes null and throws a null pointer exception. IN the try block I even have a code as try { if (session == null || session.isNew()) { //do something } else { //do otherwise } }catch(Exception e ) { //print stack trace and value of session } I get a null pointer exception and session is preinted as null but even the if block is noit executed . I printed the value of request.getSession(false);.This gives me session object ,where as the implicit session does not have this after many refresh interval . During the first few refresh both have the same value. May be some logic deep in your code invalidates session somehow? You can set up RequestDumperFilter to look at HTTP headers you (your browser) send and what is received. I don't know if that filter available in Tomcat 3.2, 'cause I use it since 4.1 time, but you can grab it from recent Tomcat distribution. Or you can use javax.servlet.http.HttpSessionListener to be notified when a session is about to be invalidated or timed out. Also note that this runs fine in Windows ,I get this problem only in UNIX . I use tomcat 3.2 in unix and view using IE in windows - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]