File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Removing browser cache Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "Removing browser cache" Watch "Removing browser cache" New topic
Author

Removing browser cache

Dilshan Edirisuriya
Ranch Hand

Joined: Apr 22, 2006
Posts: 299
I want to do a logout action in my session. When I press logout it is redirected to a new page and the session is invalidated. In the previous page I am using validation logic to validate my session. When I press back button I get the previous page which should not be displayed if the session is invalidated. So I used following headers to remove chaching in the browser.

response.setHeader("Cache-Control", "no-store, no-cache");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Expires", 0);

But when I am using this there were few problems. I am passing serveral request parameters at runtime. As soon as I press refresh all my parameters get null. So how do you avoid this scenario.

Is there another way to do this thing done


Dilshan Edirisuriya SCJP1.4, SCWCD1.4, SCBCD 5
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61302
    
  66

Originally posted by Dilshan Edirisuriya:
As soon as I press refresh all my parameters get null.

You'll need to expand on what you mean by this.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Dilshan Edirisuriya
Ranch Hand

Joined: Apr 22, 2006
Posts: 299
That means I cannot view the request parameters which I got after doing a page refresh.
[ January 07, 2008: Message edited by: Dilshan Edirisuriya ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Request parameters or request attributes?

Your request parameters (form parameters or querystring variables) should survive a page refresh. Attributes, on the other hand will not.

Take a little time to explain exactly what you're doing and exactly what you're trying to accomplish. Once we understand, someone should be able to help you.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Dilshan Edirisuriya
Ranch Hand

Joined: Apr 22, 2006
Posts: 299
Thank you Ben and Bear for your kind consideration.

It solved it was a programmatic error done by me. Now I am facing another problem. When I keep on pressing the browser back button after removing the cache I get a page not available massege. (Offline displayed page of IE) I removed the cache of all the pages so they are working fine. What have I done wrong to get such a result.

Is this the only way(removing cache) to cope up with logout session. Is there another approach. I have seen in some system they use javascript to handle this. They simply create an intermediate page and forward to that page. They use a "onload" submit to forward to the final page so that if you press back button it keep on forwarding to the final page. But is that a good solution. As soon as you disable javascript from firefox it wont work. You can go back simply.
[ January 07, 2008: Message edited by: Dilshan Edirisuriya ]
 
GeeCON Prague 2014
 
subject: Removing browser cache