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.eryansky.common.web.utils.WebUtils.java

/**
 *  Header./* ww w  .  j a v a  2  s.  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:com.gc.core.framework.utils.web.ServletUtils.java

/**
 *  Header./* w ww.  j a  v a2 s.c  om*/
 */
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", "private, max-age=" + expiresSeconds);
}

From source file:de.itsvs.cwtrpc.core.CwtRpcUtils.java

public static void addNoCacheResponseHeaders(HttpServletRequest request, HttpServletResponse response) {
    response.setHeader("Cache-Control", "no-cache, no-store, no-transform");
    response.setDateHeader("Expires", -1L);
    response.setHeader("Pragma", "no-cache");
}

From source file:com.dosport.system.utils.ServletUtils.java

/**
 *  Header.//w  w w  . ja va 2 s  . 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", "private, max-age=" + expiresSeconds);
}

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

/**
 * LastModified Header.//w w  w .  j av a  2 s  .co m
 */
public static void setLastModifiedHeader(HttpServletResponse response, long lastModifiedDate) {
    response.setDateHeader(HttpHeaders.LAST_MODIFIED, lastModifiedDate);
}

From source file:com.handpay.ibenefit.framework.util.WebUtils.java

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:io.apicurio.studio.fe.servlet.servlets.DownloadServlet.java

/**
 * Disable caching./*w w  w.  j  a  va2s  .c om*/
 * @param httpResponse
 */
private static void disableHttpCaching(HttpServletResponse httpResponse) {
    Date now = new Date();
    httpResponse.setDateHeader("Date", now.getTime()); //$NON-NLS-1$
    httpResponse.setDateHeader("Expires", expiredSinceYesterday(now)); //$NON-NLS-1$
    httpResponse.setHeader("Pragma", "no-cache"); //$NON-NLS-1$ //$NON-NLS-2$
    httpResponse.setHeader("Cache-control", "no-cache, no-store, must-revalidate"); //$NON-NLS-1$ //$NON-NLS-2$
}

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

/**
 * ?Header.//w  ww . j a  v a2  s  .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:org.agileframework.web.servlet.Servlets.java

/**
 *  Header./*from  ww w .  ja  v a  2s  .  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);
}

From source file:com.xsw.utils.Servlets.java

/**
 * ?Header.//from   ww w . ja v a 2s . c  om
 */
public static void setNoCacheHeader(HttpServletResponse response) {
    // Http 1.0 header
    response.setDateHeader("Expires", 1L);
    response.addHeader("Pragma", "no-cache");
    // Http 1.1 header
    response.setHeader("Cache-Control", "no-cache, no-store, max-age=0");
}