當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpServletResponse.addDateHeader方法代碼示例

本文整理匯總了Java中javax.servlet.http.HttpServletResponse.addDateHeader方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpServletResponse.addDateHeader方法的具體用法?Java HttpServletResponse.addDateHeader怎麽用?Java HttpServletResponse.addDateHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.servlet.http.HttpServletResponse的用法示例。


在下文中一共展示了HttpServletResponse.addDateHeader方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testExcludedResponseStatusCode

import javax.servlet.http.HttpServletResponse; //導入方法依賴的package包/類
@Test
public void testExcludedResponseStatusCode() throws Exception {
    HttpServlet servlet = new HttpServlet() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void service(HttpServletRequest request,
                HttpServletResponse response) throws ServletException,
                IOException {
            response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
            response.addHeader("ETag", "W/\"1934-1269208821000\"");
            response.addDateHeader("Date", System.currentTimeMillis());
        }
    };

    validate(servlet, null, HttpServletResponse.SC_NOT_MODIFIED);
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:18,代碼來源:TestExpiresFilter.java

示例2: testSkipBecauseExpiresIsDefined

import javax.servlet.http.HttpServletResponse; //導入方法依賴的package包/類
@Test
public void testSkipBecauseExpiresIsDefined() throws Exception {
    HttpServlet servlet = new HttpServlet() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void service(HttpServletRequest request,
                HttpServletResponse response) throws ServletException,
                IOException {
            response.setContentType("text/xml; charset=utf-8");
            response.addDateHeader("Expires", System.currentTimeMillis());
            response.getWriter().print("Hello world");
        }
    };

    validate(servlet, null);
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:18,代碼來源:TestExpiresFilter.java

示例3: prepareResponse

import javax.servlet.http.HttpServletResponse; //導入方法依賴的package包/類
@Override
protected void prepareResponse(HttpServletRequest request, //
                               HttpServletResponse response) {

    setResponseContentType(request, response);
    response.setCharacterEncoding(fastJsonConfig.getCharset().name());
    if (this.disableCaching) {
        response.addHeader("Pragma", "no-cache");
        response.addHeader("Cache-Control", "no-cache, no-store, max-age=0");
        response.addDateHeader("Expires", 1L);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:FastJsonJsonView.java

示例4: doFilter

import javax.servlet.http.HttpServletResponse; //導入方法依賴的package包/類
@Override
public void doFilter(ServletRequest req, ServletResponse res,
                     FilterChain chain)
  throws IOException, ServletException {
  HttpServletResponse httpRes = (HttpServletResponse) res;
  httpRes.setHeader("Cache-Control", "no-cache");
  long now = System.currentTimeMillis();
  httpRes.addDateHeader("Expires", now);
  httpRes.addDateHeader("Date", now);
  httpRes.addHeader("Pragma", "no-cache");
  chain.doFilter(req, res);
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:13,代碼來源:NoCacheFilter.java

示例5: doFilter

import javax.servlet.http.HttpServletResponse; //導入方法依賴的package包/類
@Override
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
    HttpServletResponse response = (HttpServletResponse) resp;

    response.addHeader("Pragma", "no-cache");
    response.addHeader("Cache-Control", "no-cache, no-store, max-age=0");
    response.addDateHeader("Expires", 1L);

    chain.doFilter(req, resp);
}
 
開發者ID:zouzhirong,項目名稱:configx,代碼行數:11,代碼來源:ClearCacheFilter.java

示例6: setRespHeaderCache

import javax.servlet.http.HttpServletResponse; //導入方法依賴的package包/類
/**
 * 設置資源緩存時間
 *
 * @param sec      緩存多少秒
 * @param request
 * @param response
 * @return
 */
public static boolean setRespHeaderCache(long sec,
        HttpServletRequest request, HttpServletResponse response)
{
    request.setAttribute("myExpire", sec);

    long adddaysM = sec * 1000;
    String maxAgeDirective = "max-age=" + sec;
    response.setHeader("Cache-Control", maxAgeDirective);
    response.setStatus(HttpServletResponse.SC_OK);
    response.addDateHeader("Last-Modified", System.currentTimeMillis());
    response.addDateHeader("Expires", System.currentTimeMillis() + adddaysM);
    return true;
}
 
開發者ID:gzxishan,項目名稱:OftenPorter,代碼行數:22,代碼來源:HttpCacheUtil.java

示例7: prepareResponse

import javax.servlet.http.HttpServletResponse; //導入方法依賴的package包/類
protected void prepareResponse(HttpServletRequest request, HttpServletResponse response) {
    setResponseContentType(request, response);
    response.setCharacterEncoding(UTF8.name());
    if (this.disableCaching) {
        response.addHeader("Pragma", "no-cache");
        response.addHeader(HttpRequest.HEADER_CACHE_CONTROL, "no-cache, no-store, max-age=0");
        response.addDateHeader(HttpRequest.HEADER_EXPIRES, 1);
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:10,代碼來源:FastJsonJsonView.java

示例8: prepareResponse

import javax.servlet.http.HttpServletResponse; //導入方法依賴的package包/類
protected void prepareResponse(HttpServletRequest request, HttpServletResponse response) {
    setResponseContentType(request, response);
    response.setCharacterEncoding(UTF8.name());
    if (this.disableCaching) {
        response.addHeader("Pragma", "no-cache");
        response.addHeader("Cache-Control", "no-cache, no-store, max-age=0");
        response.addDateHeader("Expires", 1);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:10,代碼來源:FastJsonJsonView.java

示例9: launchBasicLTI

import javax.servlet.http.HttpServletResponse; //導入方法依賴的package包/類
/**
    * Submit reflection form input database.
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    * @throws Exception
    */
   private ActionForward launchBasicLTI(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) throws IOException {
String mode = request.getParameter(AttributeNames.ATTR_MODE);
String sessionMapID = WebUtil.readStrParam(request, CommonCartridgeConstants.ATTR_SESSION_MAP_ID);
SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
CommonCartridgeItem item = getCommonCartridgeItem(request, sessionMap, mode);

ICommonCartridgeService service = getCommonCartridgeService();
WebApplicationContext wac = WebApplicationContextUtils
	.getRequiredWebApplicationContext(getServlet().getServletContext());
MessageService messageService = (MessageService) wac.getBean("commonCartridgeMessageService");

// Get the post data for the placement
String returnValues = LamsBasicLTIUtil.postLaunchHTML(service, messageService, item);

try {
    response.setContentType("text/html; charset=UTF-8");
    response.setCharacterEncoding("utf-8");
    response.addDateHeader("Expires", System.currentTimeMillis() - (1000L * 60L * 60L * 24L * 365L));
    response.addDateHeader("Last-Modified", System.currentTimeMillis());
    response.addHeader("Cache-Control",
	    "no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0");
    response.addHeader("Pragma", "no-cache");
    ServletOutputStream out = response.getOutputStream();

    out.println("<!DOCTYPE html>");
    out.println("<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">");
    out.println("<html>\n<head>");
    out.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />");
    out.println("</head>\n<body>");
    out.println(returnValues);
    out.println("</body>\n</html>");

} catch (IOException e) {
    e.printStackTrace();
    throw e;
}

return null;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:51,代碼來源:ViewItemAction.java


注:本文中的javax.servlet.http.HttpServletResponse.addDateHeader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。