Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1967
  • Last Modified:

how can i use jstl code to clear ie cache???

hi,experts,
  now i use
<%
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
%>
to clear ie cache

i want use jstl to do it,how can i do it???

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
?????

thanks!
0
hgbdelphi
Asked:
hgbdelphi
  • 4
  • 2
1 Solution
 
bloodredsunCommented:
<c:out value='${pageContext.response}'/> returns an object of class org.apache.coyote.tomcat4.CoyoteResponseFacade which implements the HttpServletResponse. So you have access to all the methods you normally would to alter reponse object values.
0
 
bloodredsunCommented:
I would rather recommend including a page fragment "nocache.jsp", using c:import that just used the scriplet above so that you take it out of your code and increase re-usability as it allows you to have that code in all your pages but only have to maintain the one version.

e.g.

nocache.jsp
--------
<%
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
%>

myPage.jsp
--------
<%@ taglib uri='http://java.sun.com/jstl/core' prefix='c' %>
<c:import  url='nocache.jsp' />
<html>
.......
0
 
bloodredsunCommented:
Actually, if you go here http://www.phptr.com/articles/article.asp?p=30946&seqNum=7 (scroll down to respose properties) you cannot alter response headers via JSTL as you only have access to 4 properties: bufferSize, characterEncoding, locale, committed
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
TimYatesCommented:
>> nocache.jsp

This is better (covers more browser versions, and sme IE bugs of old)...

<%
    // Set to expire far in the past.
    response.setHeader("Expires", "Sat, 6 May 1995 12:00:00 GMT");

    // Set standard HTTP/1.1 no-cache headers.
    response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");

    // Set IE extended HTTP/1.1 no-cache headers (use addHeader).
    response.addHeader("Cache-Control", "post-check=0, pre-check=0");

    // Set standard HTTP/1.0 no-cache header.
    response.setHeader("Pragma", "no-cache");
%>
0
 
hgbdelphiAuthor Commented:
thanks for bloodredsun and TimYates

i use <c:import  url='nocache.jsp' /> to do it now!

to TimYates
  say sorry for not give your points.:)
0
 
bloodredsunCommented:
It is possible to split points. If you are using any of TimYates' code I think it would be fair to give him some points. If you want to you can go the the Community Support topic area and ask for a mod to re-assign the points to give him some. What do you think Tim?
0
 
TimYatesCommented:
It would be nice, but this is only a 50 point question...so I'm just glad we could help :-)

hgbdelphi, for future reference, there is a "Split Points" link just above the comment box that you can use to assign points to all the different people who helped :-)

Good luck with it though :-)

Tim
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now