aspose file tools*
The moose likes JSP and the fly likes how to remove history from jsp pages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "how to remove history from jsp pages" Watch "how to remove history from jsp pages" New topic
Author

how to remove history from jsp pages

Jignesh Patel
Ranch Hand

Joined: Nov 03, 2001
Posts: 626

Hi All,
I am using struts1.1 for new web application.
My problems is JSP pages are maintains Caches.
So whenever I refresh the page it gives me old data?
What can be done to remove history?
-Jignesh
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61196
    
  66

Search this forum and the HTML forum for the terms "cache" or "caching". This has been discussed many times.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jignesh Patel
Ranch Hand

Joined: Nov 03, 2001
Posts: 626

According to your suggestion,
I searched and implemented the code which I found from the site but it is not making any impact, I think there should be some different methodology required while we implements struts.
my code
<%
response.setHeader("Cache-Control","no-store"); // HTTP 1.1
response.setHeader("Pragma","no-cache"); // HTTP 1.0
response.setDateHeader ("Expires", 0);
%>
Siddalinga Murthy
Greenhorn

Joined: Sep 17, 2001
Posts: 10
Use the attribute nocache="true" in the controller tag of your struts-config.xml
<controller....nocache="true"../>
Jignesh Patel
Ranch Hand

Joined: Nov 03, 2001
Posts: 626

Can you provide me any link where I can study the stuff?
Dumitru Husleag
Greenhorn

Joined: Oct 01, 2003
Posts: 22
Hello Jignesh,
Your problem is not on the server side but on the client side.
You need to set the right HTTP headers (look the HTTP spec) to force the browser to ask again the page and not use the cache (read more about cache and HTTP protocol).
You shoud use 'Expires, -1' and 'Control-cache, no-cache'
Keep also the 'cache-control, no-store' header if you want to reload from server your page when the user clicks Back button to reload the previous page.
I do not remenber exactly but IE 4 or 5 ignores completely one of these headers.
Good luck


Dumitru
Dumitru Husleag
Greenhorn

Joined: Oct 01, 2003
Posts: 22
My problems is JSP pages are maintains Caches.

By the way: the way you express it makes me think you do not really understand caching. Browser or proxy caches your pages (html translated pages not JSP).
Caching might be a complex problem:
- it depends on users browser setting
- it depends on your web server settings
- it depends on HTTP headers (cahe related) you set in your page (check also your HTTP protocol version)
- it depends if there is a proxy between the server and browser
Read more.
Jignesh Patel
Ranch Hand

Joined: Nov 03, 2001
Posts: 626

Hi I accept the wordings are not proper.
But the purpose was the same.
And as you said I already ask for readling link.
By the way I have implemented the solution suggested by you as follows but not impact.
<%
response.setDateHeader ("Expires", -1);
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-store");
response.setHeader("Control-Cache","no-cache");
%>
Wendal Park
Ranch Hand

Joined: Aug 28, 2001
Posts: 39
There is a trick I used before ....
Just add a dummy parameter to your URL String, then every time when a request is passed through the servlet / Action Class, apply a random number to that parameter before returning, so that the browser would see the URL link is different than last time, and will check for the latest version of the HTML page automatically.
E.g. The link for the first time is http://localhost:7001/myApp/ListItem.jsp?dummy=13920, and the second time can be http://localhost:7001/myApp/ListItem.jsp?dummy=7489, which is different from the first one.
Wendal
[ May 07, 2004: Message edited by: Wendal Park ]

MSc, BSc, SCJP 1.4<br /> <img src="graemlins/banghead.gif" border="0" alt="[banghead]" /> SCBCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to remove history from jsp pages