当前位置: 首页>>代码示例>>Java>>正文


Java ResourceAttributes.getLastModified方法代码示例

本文整理汇总了Java中org.apache.naming.resources.ResourceAttributes.getLastModified方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceAttributes.getLastModified方法的具体用法?Java ResourceAttributes.getLastModified怎么用?Java ResourceAttributes.getLastModified使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.naming.resources.ResourceAttributes的用法示例。


在下文中一共展示了ResourceAttributes.getLastModified方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkIfModifiedSince

import org.apache.naming.resources.ResourceAttributes; //导入方法依赖的package包/类
/**
 * Check if the if-modified-since condition is satisfied.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 * @param resourceAttributes File object
 * @return boolean true if the resource meets the specified condition,
 * and false if the condition is not satisfied, in which case request
 * processing is stopped
 */
protected boolean checkIfModifiedSince(HttpServletRequest request,
        HttpServletResponse response,
        ResourceAttributes resourceAttributes) {
    try {
        long headerValue = request.getDateHeader("If-Modified-Since");
        long lastModified = resourceAttributes.getLastModified();
        if (headerValue != -1) {

            // If an If-None-Match header has been specified, if modified since
            // is ignored.
            if ((request.getHeader("If-None-Match") == null)
                && (lastModified < headerValue + 1000)) {
                // The entity has not been modified since the date
                // specified by the client. This is not an error case.
                response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
                response.setHeader("ETag", resourceAttributes.getETag());

                return false;
            }
        }
    } catch (IllegalArgumentException illegalArgument) {
        return true;
    }
    return true;

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:37,代码来源:DefaultServlet.java

示例2: checkIfUnmodifiedSince

import org.apache.naming.resources.ResourceAttributes; //导入方法依赖的package包/类
/**
 * Check if the if-unmodified-since condition is satisfied.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 * @param resourceAttributes File object
 * @return boolean true if the resource meets the specified condition,
 * and false if the condition is not satisfied, in which case request
 * processing is stopped
 */
protected boolean checkIfUnmodifiedSince(HttpServletRequest request,
                                       HttpServletResponse response,
                                       ResourceAttributes resourceAttributes)
    throws IOException {
    try {
        long lastModified = resourceAttributes.getLastModified();
        long headerValue = request.getDateHeader("If-Unmodified-Since");
        if (headerValue != -1) {
            if ( lastModified >= (headerValue + 1000)) {
                // The entity has not been modified since the date
                // specified by the client. This is not an error case.
                response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
                return false;
            }
        }
    } catch(IllegalArgumentException illegalArgument) {
        return true;
    }
    return true;

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:32,代码来源:DefaultServlet.java

示例3: checkIfUnmodifiedSince

import org.apache.naming.resources.ResourceAttributes; //导入方法依赖的package包/类
/**
 * Check if the if-unmodified-since condition is satisfied.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 * @param resourceInfo File object
 * @return boolean true if the resource meets the specified condition,
 * and false if the condition is not satisfied, in which case request
 * processing is stopped
 */
protected boolean checkIfUnmodifiedSince(HttpServletRequest request,
                                       HttpServletResponse response,
                                       ResourceAttributes resourceAttributes)
    throws IOException {
    try {
        long lastModified = resourceAttributes.getLastModified();
        long headerValue = request.getDateHeader("If-Unmodified-Since");
        if (headerValue != -1) {
            if ( lastModified >= (headerValue + 1000)) {
                // The entity has not been modified since the date
                // specified by the client. This is not an error case.
                response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
                return false;
            }
        }
    } catch(IllegalArgumentException illegalArgument) {
        return true;
    }
    return true;

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:DefaultServlet.java

示例4: checkIfModifiedSince

import org.apache.naming.resources.ResourceAttributes; //导入方法依赖的package包/类
/**
 * Check if the if-modified-since condition is satisfied.
 *
 * @param request
 *            The servlet request we are processing
 * @param response
 *            The servlet response we are creating
 * @param resourceAttributes
 *            File object
 * @return boolean true if the resource meets the specified condition, and
 *         false if the condition is not satisfied, in which case request
 *         processing is stopped
 */
protected boolean checkIfModifiedSince(HttpServletRequest request, HttpServletResponse response,
		ResourceAttributes resourceAttributes) {
	try {
		long headerValue = request.getDateHeader("If-Modified-Since");
		long lastModified = resourceAttributes.getLastModified();
		if (headerValue != -1) {

			// If an If-None-Match header has been specified, if modified
			// since
			// is ignored.
			if ((request.getHeader("If-None-Match") == null) && (lastModified < headerValue + 1000)) {
				// The entity has not been modified since the date
				// specified by the client. This is not an error case.
				response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
				response.setHeader("ETag", resourceAttributes.getETag());

				return false;
			}
		}
	} catch (IllegalArgumentException illegalArgument) {
		return true;
	}
	return true;

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:39,代码来源:DefaultServlet.java

示例5: checkIfUnmodifiedSince

import org.apache.naming.resources.ResourceAttributes; //导入方法依赖的package包/类
/**
 * Check if the if-unmodified-since condition is satisfied.
 *
 * @param request
 *            The servlet request we are processing
 * @param response
 *            The servlet response we are creating
 * @param resourceAttributes
 *            File object
 * @return boolean true if the resource meets the specified condition, and
 *         false if the condition is not satisfied, in which case request
 *         processing is stopped
 */
protected boolean checkIfUnmodifiedSince(HttpServletRequest request, HttpServletResponse response,
		ResourceAttributes resourceAttributes) throws IOException {
	try {
		long lastModified = resourceAttributes.getLastModified();
		long headerValue = request.getDateHeader("If-Unmodified-Since");
		if (headerValue != -1) {
			if (lastModified >= (headerValue + 1000)) {
				// The entity has not been modified since the date
				// specified by the client. This is not an error case.
				response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
				return false;
			}
		}
	} catch (IllegalArgumentException illegalArgument) {
		return true;
	}
	return true;

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:33,代码来源:DefaultServlet.java

示例6: checkIfModifiedSince

import org.apache.naming.resources.ResourceAttributes; //导入方法依赖的package包/类
/**
 * Check if the if-modified-since condition is satisfied.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 * @param resourceInfo File object
 * @return boolean true if the resource meets the specified condition,
 * and false if the condition is not satisfied, in which case request
 * processing is stopped
 */
protected boolean checkIfModifiedSince(HttpServletRequest request,
                                     HttpServletResponse response,
                                     ResourceAttributes resourceAttributes)
    throws IOException {
    try {
        long headerValue = request.getDateHeader("If-Modified-Since");
        long lastModified = resourceAttributes.getLastModified();
        if (headerValue != -1) {

            // If an If-None-Match header has been specified, if modified since
            // is ignored.
            if ((request.getHeader("If-None-Match") == null)
                && (lastModified < headerValue + 1000)) {
                // The entity has not been modified since the date
                // specified by the client. This is not an error case.
                response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
                response.setHeader("ETag", resourceAttributes.getETag());

                return false;
            }
        }
    } catch (IllegalArgumentException illegalArgument) {
        return true;
    }
    return true;

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:38,代码来源:DefaultServlet.java

示例7: getResourceAttributes

import org.apache.naming.resources.ResourceAttributes; //导入方法依赖的package包/类
@Override
public Long[] getResourceAttributes(String name, Context context) {
  Long[] result = new Long[2];
  try {
    ResourceAttributes resource = (ResourceAttributes) context.getResources().getAttributes(name);
    result[0] = resource.getContentLength();
    result[1] = resource.getLastModified();
  } catch (NamingException ex) {
    logger.trace("", ex);
  }
  return result;
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:13,代码来源:Tomcat70ContainerAdapter.java

示例8: getResourceAttributes

import org.apache.naming.resources.ResourceAttributes; //导入方法依赖的package包/类
public Long[] getResourceAttributes(String name, Context context) {
 Long result[] = new Long[2];
	try {
		ResourceAttributes resource = (ResourceAttributes) context.getResources().getAttributes(name);
		result[0] = resource.getContentLength();
		result[1] = resource.getLastModified();
	} catch (NamingException e) {
		//Don't care
	}

	return result;
}
 
开发者ID:andresol,项目名称:psi-probe-plus,代码行数:13,代码来源:Tomcat60ContainerAdaptor.java

示例9: getResourceAttributes

import org.apache.naming.resources.ResourceAttributes; //导入方法依赖的package包/类
public Long[] getResourceAttributes(String name, Context context) {
	Long result[] = new Long[2];
	ResourceAttributes resource = (ResourceAttributes) context.getResources().getAttributes(name);
	result[0] = resource.getContentLength();
	result[1] = resource.getLastModified();
	return result;
}
 
开发者ID:andresol,项目名称:psi-probe-plus,代码行数:8,代码来源:Tomcat70ContainerAdaptor.java


注:本文中的org.apache.naming.resources.ResourceAttributes.getLastModified方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。