List of usage examples for javax.servlet.http HttpServletRequest getDateHeader
public long getDateHeader(String name);
long
value that represents a Date
object. From source file:com.mmd.mssp.util.WebUtil.java
/** * * @param request/* w w w . ja v a 2 s .co m*/ * @return ?? -1 */ public static long getIfModifiedSince(HttpServletRequest request) { try { long since = request.getDateHeader(IF_MODIFIED_SINCE); return since; } catch (Exception ex) { logger.warn("data time parse error ! :" + ex.getMessage()); } return -1L; }
From source file:com.ccf.util.ModDateHeaderUtil.java
/** * 1/* w ww . ja v a 2 s .c o m*/ * @param request * @param response * @return */ public static boolean respondIfNotModifiedOneDay(HttpServletRequest request, HttpServletResponse response) { long sinceDate = request.getDateHeader("If-Modified-Since"); // truncate to seconds long lastModifiedTimeMillis = System.currentTimeMillis() - 24 * 60 * 60 * 1000; log.debug("since date = " + sinceDate); log.debug("last mod date (trucated to seconds) = " + lastModifiedTimeMillis); if (lastModifiedTimeMillis <= sinceDate) { log.debug("NOT MODIFIED " + request.getRequestURL()); //response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); return true; } else { return false; } }
From source file:com.ccf.util.ModDateHeaderUtil.java
/** * Sets the HTTP response status to 304 (NOT MODIFIED) if the request contains an * If-Modified-Since header that specifies a time that is * at or after the time specified by the value of lastModifiedTimeMillis * <em>truncated to second granularity</em>. Returns true if * the response status was set, false if not. * * @param request//from ww w . j a v a2 s .c o m * @param response * @param lastModifiedTimeMillis * @return true if a response status was sent, false otherwise. */ public static boolean respondIfNotModified(HttpServletRequest request, HttpServletResponse response, long lastModifiedTimeMillis) { long sinceDate = request.getDateHeader("If-Modified-Since"); // truncate to seconds lastModifiedTimeMillis -= (lastModifiedTimeMillis % 1000); log.debug("since date = " + sinceDate); log.debug("last mod date (trucated to seconds) = " + lastModifiedTimeMillis); if (lastModifiedTimeMillis <= sinceDate) { log.debug("NOT MODIFIED " + request.getRequestURL()); response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); return true; } else { return false; } }
From source file:org.apache.roller.weblogger.ui.rendering.util.ModDateHeaderUtil.java
/** * Sets the HTTP response status to 304 (NOT MODIFIED) if the request contains an * If-Modified-Since header that specifies a time that is * at or after the time specified by the value of lastModifiedTimeMillis * <em>truncated to second granularity</em>. Returns true if * the response status was set, false if not. * * @param request/*from ww w .j a v a2 s . c o m*/ * @param response * @param lastModifiedTimeMillis * @return true if a response status was sent, false otherwise. */ public static boolean respondIfNotModified(HttpServletRequest request, HttpServletResponse response, long lastModifiedTimeMillis) { long sinceDate = 0; try { sinceDate = request.getDateHeader("If-Modified-Since"); } catch (IllegalArgumentException ex) { // this indicates there was some problem parsing the header value as a date return false; } // truncate to seconds lastModifiedTimeMillis -= (lastModifiedTimeMillis % 1000); log.debug("since date = " + sinceDate); log.debug("last mod date (trucated to seconds) = " + lastModifiedTimeMillis); if (lastModifiedTimeMillis <= sinceDate) { log.debug("NOT MODIFIED " + request.getRequestURL()); response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); return true; } else { return false; } }
From source file:com.dosport.system.utils.ServletUtils.java
/** * ??If-Modified-Since Header, ?./* w w w. ja v a2s. c o m*/ * * , checkIfModifyfalse ,304 not modify status. * * @param lastModified * ?. */ public static boolean checkIfModifiedSince(HttpServletRequest request, HttpServletResponse response, long lastModified) { long ifModifiedSince = request.getDateHeader("If-Modified-Since"); if ((ifModifiedSince != -1) && (lastModified < ifModifiedSince + 1000)) { response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); return false; } return true; }
From source file:com.handpay.ibenefit.framework.util.WebUtils.java
public static boolean checkIfModifiedSince(HttpServletRequest request, HttpServletResponse response, long lastModified) { long ifModifiedSince = request.getDateHeader("If-Modified-Since"); if ((ifModifiedSince != -1) && (lastModified < ifModifiedSince + 1000)) { response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); return false; }/*from w ww .j ava 2 s .c o m*/ return true; }
From source file:cc.sion.core.web.Servlets.java
/** * ??If-Modified-Since Header, ?.//w w w . jav a 2s. c om * * , checkIfModifyfalse ,304 not modify status. * * @param lastModified ?. */ public static boolean checkIfModifiedSince(HttpServletRequest request, HttpServletResponse response, long lastModified) { long ifModifiedSince = request.getDateHeader(HttpHeaders.IF_MODIFIED_SINCE); if ((ifModifiedSince != -1) && (lastModified < (ifModifiedSince + 1000))) { response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); return false; } return true; }
From source file:cn.com.qiqi.order.utils.Servlets.java
/** * ??If-Modified-Since Header, ?.//from w ww . j a v a 2s . com * * , checkIfModifyfalse ,304 not modify status. * * @param lastModified ?. */ public static boolean checkIfModifiedSince(HttpServletRequest request, HttpServletResponse response, long lastModified) { long ifModifiedSince = request.getDateHeader(HttpHeaders.IF_MODIFIED_SINCE); if ((ifModifiedSince != -1) && (lastModified < ifModifiedSince + 1000)) { response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); return false; } return true; }
From source file:com.cnksi.core.web.utils.Servlets.java
/** * ??If-Modified-Since Header, ?.// www . java 2 s .c o m * * , checkIfModifyfalse ,304 not modify status. * * @param lastModified ?. */ public static boolean checkIfModifiedSince(HttpServletRequest request, HttpServletResponse response, long lastModified) { long ifModifiedSince = request.getDateHeader(HttpHeaders.IF_MODIFIED_SINCE); if ((ifModifiedSince != -1) && (lastModified < ifModifiedSince + 1000)) { response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); return false; } return true; }
From source file:com.meltmedia.cadmium.servlets.FileServletTest.java
public static HttpServletRequest mockGetWithIfUnmodifiedSince(String pathInfo, Long lastModified) { HttpServletRequest request = mockGet(pathInfo); when(request.getDateHeader(IF_UNMODIFIED_SINCE_HEADER)).thenReturn(lastModified); return request; }