views:

13

answers:

1

Hi,

I am new to struts2. I have page to display the list of elements. Each element contains the link to open the another window to show the related information. First while clicking on that link its fetching deatils from db and working correctly. but second time it is showing previously shown data. the same thing is working in IE 7 correctly. In IE8 its making this problem.how to reslove it programatically?

+1  A: 

Make sure you're explicitly disabling caching on your pages. The following would be how it's done at the top of a JSP in a scriptlet:

<%
    response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
    response.setHeader("Pragma","no-cache"); //HTTP 1.0
    response.setDateHeader ("Expires", -1); 
%>

For extra IE cache busting power, you can add a second <head> below your </body>. The complete code, including the above scriplet looks as follows:

<%
    response.setHeader("Cache-Control","no-cache"); 
    response.setHeader("Pragma","no-cache"); 
    response.setDateHeader ("Expires", -1);
%>
<html>
<head></head> 
<body>
   Your body content
</body>

<!--[if IE]>
<head> 
    <meta http-equiv="pragma" content="no-cache"/> 
    <meta http-equiv="Expires" content="-1"/> 
</head> 
<![endif]-->

</html>

Notice that you serve the second, invalid <head> in conditional comments so only our special friend IE gets it.

Pat