Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Logout Servlet Not working properly  RSS feed

 
Pranit Sonawane
Ranch Hand
Posts: 172
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all below is my logout servlet and when I press logout button it does logout the user but it is not clearing the cookie so when press the back button on the browser it shows the home page of the user. What should be done!

 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What the browser does when the back button is pressed is up to the browser. In most cases there it will not send a new request to the server, but will just display the page from its cache.

What problem do you perceive in that behavior?
 
Pranit Sonawane
Ranch Hand
Posts: 172
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the quick reply!
You are right sir. but I have used the same code for couple of other project and have been using the same chrome browser to run them. It works..but only for this time its not working. the same code.

now what is happening?
I go to the logine page
enter my login ID and password
then i get directed to the home page.
now from the same home page i press logout button and i logout properly and get redirected to the login page.
but then if I press the back button, It gets logged in automatically and shows that i have logged in back again.

Now as you said that the browser shows its cashed page. Is there any option to clear that cache also. If yes then please help me.
Thanks!
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One thing you can try is fiddling with the cache headers: https://www.coderanch.com/how-to/java/NoCacheHeaders

It gets logged in automatically and shows that i have logged in back again.

Is that really what's happening? Or is it merely showing the page you would see if you were logged in? The only way to log back in would be a round trip to the server (which you can check on the server), assuming that the cookies get properly cleared. I suppose it's possible if you had used a GET instead of a POST for the login.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!