• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Refresh Using setheader on response

 
robin singal
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

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.

Thanks & Regards
Robin
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I sounds like you maintain state (ie have instance variables) in your servlet. If you do, remove them immediately please! These values are shared and therefore written by one a then read by others.
 
robin singal
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means i should make all variables local to a particular function and pass parameters as & when required rather than declaring class or instance variables???

Thanks
 
Hendy Setyo Mulyo
Ranch Hand
Posts: 219
Firefox Browser Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct.
 
robin singal
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Thanks
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it working better now?
 
robin singal
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it is working now thanks all for the info.

Regards Robin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic