-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Martin,
Martin B. Smith wrote:
> With Tomcat 5.5 , I'm using the (what I assume to be typical) pattern:
>
> --
> if(!request.isRequestedSessionIdValid() || request.getSession(false) ==
> null)
> {
> // some code to bail out and return an error
> }
>
> HttpSession session = request.getSession();
I've never done this. I typically just do:
HttpSession nonRequiredSession = request.getSession(false);
if(null === nonRequiredSession)
// I gots no session
else
// I have a session
> and yet, later on in my code, a call to session.setAttribute() throws
> the following exception (see bottom of email)... what am I doing wrong?
> Throwable/Exception cause: java.lang.IllegalStateException:
> setAttribute: Session already invalidated
Presumably, your code has called session.invalidate() during the
processing of the current request. I'm not sure what happens if you do this:
session = request.getSession();
session.invalidate();
session = request.getSession();
session.setAttribute("foo", "bar");
Will this fail on the setAttribute, or will the second getSession give
you a new session?
My guess is that your code does the above, but without the second
request.getSession(), so you end up with an invalidated session into
which you are trying to shove attributes.
Maybe you could post the code?
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAklCpmcACgkQ9CaO5/Lv0PDVsACfSIj+zQgexu2CWGcgTsdUzhDv
jpoAnjljuncyiTQP7u5uFagYS/Mwuw3b
=z0Dn
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]