本文整理匯總了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;
}