Hi Chris, Thanks for your response. I actually don't invalidate the current session there. That's what is so frustrating -- the code snippet I provided is at the very top of the method, and there's no more reference to the session or request until using setAttribute.
I don't mind providing the code -- it's at http://java.pastebin.ca/1283742. Actually, looking at it in the pastebin -- could it be that I'm setting an attribute FOR the error about a missing session? Hmm.... did I just solve my own problem? Martin Christopher Schultz wrote: > 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 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org -- Martin Smith, Systems Developer mart...@bebr.ufl.edu Bureau of Economic and Business Research University of Florida (352) 392-0171 Ext. 221 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org