List of usage examples for javax.servlet.http HttpServletResponse setDateHeader
public void setDateHeader(String name, long date);
From source file:br.on.daed.services.filters.CacheControlFilter.java
@Override public void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletResponse resp = (HttpServletResponse) response; resp.setHeader("Expires", "Tue, 03 Jul 2001 06:00:00 GMT"); resp.setDateHeader("Last-Modified", new Date().getTime()); resp.setHeader("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0"); resp.setHeader("Pragma", "no-cache"); chain.doFilter(request, response);/* ww w . j ava 2 s.com*/ }
From source file:com.fanya.p2p.front.user.jcaptcha.JCaptchaFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { response.setDateHeader("Expires", 0L); response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate"); response.addHeader("Cache-Control", "post-check=0, pre-check=0"); response.setHeader("Pragma", "no-cache"); response.setContentType("image/jpeg"); String id = request.getRequestedSessionId(); BufferedImage bi = JCaptcha.captchaService.getImageChallengeForID(id); ServletOutputStream out = response.getOutputStream(); ImageIO.write(bi, "jpg", out); try {//ww w . j a va 2 s.c o m out.flush(); } finally { out.close(); } }
From source file:com.ace.erp.filter.jcaptcha.JCaptchaFilter.java
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { response.setDateHeader("Expires", 0L); response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate"); response.addHeader("Cache-Control", "post-check=0, pre-check=0"); response.setHeader("Pragma", "no-cache"); response.setContentType("image/jpeg"); ServletOutputStream out = response.getOutputStream(); try {//from w w w. j a v a 2s .c o m String id = request.getSession(true).getId(); //String id = request.getRequestedSessionId(); BufferedImage bi = JCaptcha.captchaService.getImageChallengeForID(id); ImageIO.write(bi, "jpg", out); out.flush(); } finally { out.close(); } }
From source file:org.fishwife.jrugged.spring.StatusController.java
private void setCachingHeaders(HttpServletResponse resp) { long now = System.currentTimeMillis(); resp.setDateHeader("Date", now); resp.setDateHeader("Expires", now); resp.setHeader("Cache-Control", "no-cache"); }
From source file:org.jasig.cas.web.flow.AbstractLogoutAction.java
/** * Prevent caching by adding the appropriate headers. * Copied from the <code>preventCaching</code> method in the {@link WebContentGenerator} class. * * @param response the HTTP response.//from ww w . j a va2 s.c o m */ protected final void preventCaching(final HttpServletResponse response) { response.setHeader("Pragma", "no-cache"); response.setDateHeader("Expires", 1L); response.setHeader("Cache-Control", "no-cache"); response.addHeader("Cache-Control", "no-store"); }
From source file:de.itsvs.cwtrpc.security.AbstractRpcSuccessHandler.java
protected void addNoCacheResponseHeaders(HttpServletRequest request, HttpServletResponse response) { response.setHeader("Cache-Control", "no-cache, no-store"); response.setDateHeader("Expires", -1L); response.setHeader("Pragma", "no-cache"); }
From source file:jp.co.opentone.bsol.linkbinder.view.servlet.WebResourceServlet.java
protected void setHeader(HttpServletResponse response, String path) { response.setDateHeader("Last-Modified", System.currentTimeMillis()); Calendar expires = Calendar.getInstance(); expires.add(Calendar.DAY_OF_YEAR, 7); response.setDateHeader("Expires", expires.getTimeInMillis()); //12 hours: 43200 = 60s * 60 * 12 response.setHeader("Cache-Control", "max-age=43200"); response.setHeader("Pragma", ""); String contentType = getContentType(path); if (StringUtils.isNotEmpty(contentType)) { response.setContentType(contentType); }/*from www . j ava 2 s.co m*/ }
From source file:org.apache.myfaces.custom.skin.webapp.CachingStyleSheetLoader.java
/** * Output http headers telling the browser (and possibly intermediate caches) how * to cache this data./* w w w . j av a 2 s . co m*/ * <p> * The expiry time in this header info is set to 7 days. This is not a problem as * the overall URI contains a "cache key" that changes whenever the webapp is * redeployed (see AddResource.getCacheKey), meaning that all browsers will * effectively reload files on webapp redeploy. */ protected void defineCaching(HttpServletRequest request, HttpServletResponse response, long lastModified) { response.setDateHeader("Last-Modified", lastModified); Calendar expires = Calendar.getInstance(); expires.add(Calendar.DAY_OF_YEAR, 7); response.setDateHeader("Expires", expires.getTimeInMillis()); //12 hours: 43200 = 60s * 60 * 12 response.setHeader("Cache-Control", "max-age=43200"); response.setHeader("Pragma", ""); }
From source file:org.olat.core.gui.media.ServletUtil.java
public static void setStringResourceHeaders(HttpServletResponse response) { // we ignore the accept-charset from the request and always write in utf-8 // -> see comment below response.setContentType("text/html;charset=utf-8"); // never allow to cache pages since they contain a timestamp valid only once // HTTP 1.1/*www. ja v a 2 s .co m*/ response.setHeader("Cache-Control", "private, no-cache, no-store, must-revalidate, proxy-revalidate, s-maxage=0, max-age=0"); // HTTP 1.0 response.setHeader("Pragma", "no-cache"); response.setDateHeader("Expires", 0); }
From source file:com.cloudseal.spring.client.namespace.CloudSealLogoutImageFilter.java
protected void preventCaching(HttpServletResponse response) { Date now = new Date(); response.setHeader("Pragma", "no-cache"); response.setDateHeader("Date", now.getTime()); response.setDateHeader("Expires", now.getTime() - 86400000L); // one day old response.setHeader("Cache-Control", "no-cache"); response.addHeader("Cache-Control", "no-store"); response.addHeader("Cache-Control", "must-revalidate"); }