clearing browser cache

hi all

good morning...

Here iam struggling from simple problem..can any one help me in this issue...my query is how to clear the window history after log out...

i will explain clearly here...When a user is logged in and after logged out if he pressed window back button it is displaying the page is expired but when we click the refresh button(f5) it will again post the data with your user name and password....and displaying the inbox page

in my java program iam invalidating the session also

request.getSession().invalidate();

here iam clearing the cache also in jsp's

So can any one help me how to clear the browser history......

My requirement is if user logged out if he pressed

1.back button (or)

the browser should not display any thing what we previously did....it will should go to login page...

How should i do that ...

Please i requesting you guys ...give me some process...how should i do that.....its a great help for me....

other wise give me some good method to avoid this problem...that i can solve my problem here.....

Thanking you

khushwinder

[1159 byte] By [chahala] at [2007-11-27 1:25:00]
# 1

Hi,

a very tricky question as the caching is always dependent on the client browser side however from the server side we can expire the page content and maintain pragama status.but there are few cases reported where that can fail.

however, you can definately give it a try by using

response.setHeader("Pragma","no-cache");

request.setResponseHeader("Expires","-1");

request.setResponseHeader("Cache-Control","private,no-store,no-cache");

At the controller level.

and make use of

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">

<META HTTP-EQUIV="Expires" CONTENT="-1">

...............

............

.......

.....

at the view (JSP) level

however, you can make use of the link below which speaks about handling logout problem effectively.

http://www.javaworld.com/javaworld/jw-09-2004/jw-0927-logout.html

http://www.caucho.com/resin-3.1/examples/security-basic/index.xtp

http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=7&t=004586

Hope this might help :)

REGARDS,

RaHuL

RahulSharnaa at 2007-7-12 0:17:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

> but there are few cases reported where that can fail.

Usually this is caused by bad proxies.

> response.setHeader("Pragma","no-cache");

> request.setResponseHeader("Expires","-1");

> request.setResponseHeader("Cache-Control","private,no-

> store,no-cache");

For the last two, rather use HttpServletResponse#setHeader().

> At the controller level.

>

>

> and make use of

>

> <META HTTP-EQUIV="Pragma" CONTENT="no-cache">

> <META HTTP-EQUIV="Expires" CONTENT="-1">

> ...............

> ............

> .......

> .....

>

> at the view (JSP) level

The both approaches will achieve exactly the same (however the response has one more header set, but this can be done in the meta tag too though). Rather use the one or the other. You don't need to do it both. I recommend to do it at HTML level (that is, using the HTML meta tags). Then this can always be overridden programatically by HttpServletResponse#setHeader().

The complete set:

<meta http-equiv="cache-control" content="max-age=0, must-revalidate, no-cache, no-store, private">

<meta http-equiv="expires" content="-1">

<meta http-equiv="pragma" content="no-cache">

BalusCa at 2007-7-12 0:17:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Hello SirThanx a lot :)Bcz of u people i have solved my probelm.Thanx once again.
chahalkhushwindera at 2007-7-12 0:17:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

response.setHeader("Cache-Control","pre-check=0,post-heck=0,must-revalidate,s-maxage=0,max-age=0,no-cache");

response.setHeader("Pragma","no-cache");

response.setDateHeader ("Expires", -1);

I am using this to clear the history.My problem is when we click on back button once it work fine.the forward button also works.....but if we click on back button more than once and then click on forward........woooooooosh.........it starts resubmitting the form on its own...............Any solution?

Deepamania at 2007-7-12 0:17:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Implement PRG pattern. POST-Redirect-GET. When the POST is finished, but no response is sent yet, then do a HttpServletResponse#sendRedirect() to the requested page. This creates a new GET request and therefore the POST data won't be resubmitted when you refreshes the request.
BalusCa at 2007-7-12 0:17:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

Thanks for the solution but i guess u didnt understand the prob.

When I use response.setHeader("Cache-Control","pre-check=0,post-check=0,must-revalidate,s-maxage=0,max-age=0,no-store"); //HTTP 1.1

response.setHeader("Pragma","no-cache"); //HTTP 1.0

response.setDateHeader ("Expires", 0);

If we click back button once and then forward button it works well. but......

while we are on page 1 and after clicking back button more than once if we click forward.....it shows the page1 again.

If we are expiring the page the page1 also should not be saved in history. And when it is working well when back button is clicked once then y not when its clicked twice or any number of times?

Deepamania at 2007-7-12 0:17:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
I understood the problem clearly.
BalusCa at 2007-7-12 0:17:06 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...