当前位置: 首页>>代码示例>>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;未经允许,请勿转载。