I have some questions about synchronization of session variables. I�m storing the name of a jsp file in the http session. I use that name later to include the jsp file in another jsp page. The First interesting thing I came across when I started doing this was that I couldn�t find a way to test if the session was active and all variables were there without testing for null value for variables. I�m thinking may I missed something when I was researching this, if anyone has any hints please enlighten me. Anyway I decided to set a variable that acts like a flag. It would get a value whenever a session is created and hold it until the session is expired. I then test for the value of the flag in my doPost(). My question is do I need to use synchronized when I test the flag? I think I don�t because synchronize is used only when the value of an instance variable is modified. In my case the flag is not an instance variable and I am not updating it, it�s created when a new session is created. Thanks in advance for your advice.
Check out methods on javax.servlet.http.HttpSession. Especially, the getCreationTime(), getLastAccessedTime() and isNew(). What is wrong with checking for nulls anyway? Why synchronize? You don't share sessions. [ June 04, 2003: Message edited by: Murali Nanchala ]
"It is almost always answered in the API" - Murali Nanchala
subject: testing a session variable and synchronized question