You are not guaranteed to have a valid session at this point of your code.
It depends on how you retrieved the session variable. If you called
request.getSession() or request.getSession(true), then a session will be
created for you if the request does not have a valid session. If you call
request.getSession(false), a session will not be created. In this latter
case, session will equal null.

-----Original Message-----
From: Frank W. Zammetti [mailto:[EMAIL PROTECTED] 
Sent: Monday, November 08, 2004 3:49 PM
To: Struts Users Mailing List
Subject: Re: Session invalidation problem

Another good point, and I'll add code to catch that.  But, as I 
understand it, session would never be null (not at this point in the 
code anyway, which is inside an Action) because a session would have 
been established by now anyway.

Also, the exception wasn't in this section of code anyway, it actually 
happens about 20 lines after this.  I'm going to take your suggestion 
anyway because I like adding checks that don't hurt anything, might save 
me a headache down the road, but I don't think this will address my 
initial problem.

Thanks Luiz!

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

Luiz Esmiralha wrote:
> On Mon, 8 Nov 2004 11:52:14 -0800 (PST), [EMAIL PROTECTED]
> <[EMAIL PROTECTED]> wrote:
> 
>>if (session == null || session.getAttribute("sessionAlive") == null) {
>>  request.setAttribute("message", "Your session timed out.  Please log on
again.");
>>  session.invalidate();
>>  return mapping.findForward("reload");
>>}
> 
> 
> Calling session.invalidate() will throw a NullPointerException if
> session == null.
> 
> ---------------------------------------------------------------------
> 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]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to