Example usage for javax.servlet.http HttpServletResponse setDateHeader

List of usage examples for javax.servlet.http HttpServletResponse setDateHeader

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletResponse setDateHeader.

Prototype

public void setDateHeader(String name, long date);

Source Link

Document

Sets a response header with the given name and date-value.

Usage

From source file:com.cnksi.core.web.utils.Servlets.java

/**
 * LastModified Header.//w  w w .  ja va2 s .c  o m
 */
public static void setLastModifiedHeader(HttpServletResponse response, long lastModifiedDate) {

    response.setDateHeader(HttpHeaders.LAST_MODIFIED, lastModifiedDate);
}

From source file:com.sap.data.core.web.Servlets.java

/**
 *  Header./*from   www .j  a v a  2s.  c  om*/
 */
public static void setExpiresHeader(HttpServletResponse response, long expiresSeconds) {
    //Http 1.0 header, set a fix expires date.
    response.setDateHeader("Expires", System.currentTimeMillis() + expiresSeconds * 1000);
    //Http 1.1 header, set a time after now.
    response.setHeader("Cache-Control", "private, max-age=" + expiresSeconds);
}

From source file:com.sobey.framework.utils.Servlets.java

/**
 * ?Header.//from   ww w .ja  va2s . co m
 */
public static void setNoCacheHeader(HttpServletResponse response) {

    // Http 1.0 header

    response.setDateHeader(HttpHeaders.EXPIRES, 1L);

    response.addHeader(HttpHeaders.PRAGMA, "no-cache");

    // Http 1.1 header

    response.setHeader(HttpHeaders.CACHE_CONTROL, "no-cache, no-store, max-age=0");
}

From source file:com.cnksi.core.web.utils.Servlets.java

/**
 * ?Header./*from  w  w  w .  j av  a  2  s .  c o  m*/
 */
public static void setNoCacheHeader(HttpServletResponse response) {

    // Http 1.0 header
    response.setDateHeader(HttpHeaders.EXPIRES, 1L);
    response.addHeader(HttpHeaders.PRAGMA, "no-cache");
    // Http 1.1 header
    response.setHeader(HttpHeaders.CACHE_CONTROL, "no-cache, no-store, max-age=0");
}

From source file:com.klwork.common.utils.WebUtils.java

/**
 * Header./*  w  ww.  j a  v  a2 s .c om*/
 */
public static void setNoCacheHeader(HttpServletResponse response) {
    //Http 1.0 header
    response.setDateHeader("Expires", 0);
    //Http 1.1 header
    response.setHeader("Cache-Control", "no-cache");
}

From source file:com.manydesigns.elements.servlet.ServletUtils.java

/**
 * Marks the resource returned to a web client to be stored in cache for a very long time.
 * The resource is marked to be cached privately, i.e. on the client only, not in intermediate caches like proxies.
 * @param response the HTTP response whose headers are set.
 *//*from   w w  w .j  a v  a  2  s  .co m*/
public static void markCacheableForever(HttpServletResponse response) {
    long expiresAfterMillis = System.currentTimeMillis() + ONE_YEAR_MILLIS;
    response.setHeader(ServletConstants.HTTP_PRAGMA, "");
    response.setDateHeader(ServletConstants.HTTP_EXPIRES, expiresAfterMillis);
    //Private - only authorized users can cache the content
    response.setHeader(ServletConstants.HTTP_CACHE_CONTROL, ServletConstants.HTTP_CACHE_CONTROL_PRIVATE);
    response.addHeader(ServletConstants.HTTP_CACHE_CONTROL,
            ServletConstants.HTTP_CACHE_CONTROL_MAX_AGE + ONE_YEAR_MILLIS);
}

From source file:org.jahia.utils.WebUtils.java

/**
 * Sets proper response headers to cache current response for the specified number of seconds.
 * /*from  w ww  .  ja  v  a 2 s.  c o  m*/
 * @param expiresSeconds
 * @param response
 *            current response object
 */
public static void setCacheHeaders(long expiresSeconds, HttpServletResponse response) {
    response.setHeader("Cache-Control", "public, max-age=" + expiresSeconds);
    response.setDateHeader("Expires", System.currentTimeMillis() + expiresSeconds * 1000L);
}

From source file:cc.sion.core.web.Servlets.java

/**
 *  Header.// w w  w  .j  a va  2  s .  c om
 */
public static void setExpiresHeader(HttpServletResponse response, long expiresSeconds) {
    // Http 1.0 header, set a fix expires date.
    response.setDateHeader(HttpHeaders.EXPIRES, System.currentTimeMillis() + (expiresSeconds * 1000));
    // Http 1.1 header, set a time after now.
    response.setHeader(HttpHeaders.CACHE_CONTROL, "private, max-age=" + expiresSeconds);
}

From source file:com.klwork.common.utils.WebUtils.java

/**
 *  Header./*from w w w . ja v  a2s.  c o  m*/
 */
public static void setExpiresHeader(HttpServletResponse response, long expiresSeconds) {
    //Http 1.0 header
    response.setDateHeader("Expires", System.currentTimeMillis() + expiresSeconds * 1000);
    //Http 1.1 header
    response.setHeader("Cache-Control", "max-age=" + expiresSeconds);
}

From source file:cn.com.qiqi.order.utils.Servlets.java

/**
 *  Header.//from  w w w.j ava2 s.  c o  m
 */
public static void setExpiresHeader(HttpServletResponse response, long expiresSeconds) {
    // Http 1.0 header, set a fix expires date.
    response.setDateHeader(HttpHeaders.EXPIRES, System.currentTimeMillis() + expiresSeconds * 1000);
    // Http 1.1 header, set a time after now.
    response.setHeader(HttpHeaders.CACHE_CONTROL, "private, max-age=" + expiresSeconds);
}