I have a web application which is totally servlet based, when i use the
and deploy my code on my local machine and let other clients access the application deployed on my machine. Everything works just fine before the refresh but after 15 seconds the last changes made by one client are reflected in all the machines. What i want is when page refresh takes place it do so, not affecting the other clients.
There was one more observation when one logs out. The other client browser says your session is expired.
I have used
where hs is declared private to get the session.
About the structure of my app : I am using four java classes one represents home page,one authorizes and takes to the main page of application and one is for signing out.
Do not ever declare instance variables in Servlet since they will share their values for all the clients who access the same servlet. Always declare local variables in methods and pass them through parameters to other methods.
Hi As asked i removed all instance variables from the 4 servlets i am using but still i am facing the same problem as before.
I am explaining my application in more detail (what exactly i am doing):
1st Servlet -- I am displaying the home page which will send username and password to the 2nd Servlet;
2nd Servlet -- Checks the parameters and if username pass. correct then redirects to 3rd Servlet.
3rd Servlet -- Now here is All the stuff happening in doget() and doPost() i am calling various method which connect to database and retrieve values and pass on to other methods. Now everything is local. I am passing values as parameters to different functions. Here i have used setHeader in both get and post requests. Now when i click signout here it takes me to 4th servlet.
4th Servlet -- It invalidates the session redirects to the 1st Servlet.