本文整理汇总了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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}