Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to remove history from jsp pages

 
Jignesh Patel
Ranch Hand
Posts: 626
Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65115
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Search this forum and the HTML forum for the terms "cache" or "caching". This has been discussed many times.
 
Jignesh Patel
Ranch Hand
Posts: 626
Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the attribute nocache="true" in the controller tag of your struts-config.xml
<controller....nocache="true"../>
 
Jignesh Patel
Ranch Hand
Posts: 626
Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you provide me any link where I can study the stuff?
 
Dumitru Husleag
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 Husleag
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 626
Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic