public void service(ServletRequest req, ServletResponse res)
throws ServletException, IOException
HttpServletRequest request;
HttpServletResponse response;
if (!(req instanceof HttpServletRequest &&
res instanceof HttpServletResponse)) {
throw new ServletException("non-HTTP request or response");
request = (HttpServletRequest) req;
response = (HttpServletResponse) res;
service(request, response);
protected void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
String method = req.getMethod();
if (method.equals(METHOD_GET)) {
long lastModified = getLastModified(req);
if (lastModified == -1) {
// servlet doesn't support if-modified-since, no reason
// to go through further expensive logic
long ifModifiedSince = req.getDateHeader(HEADER_IFMODSINCE);
if (ifModifiedSince < lastModified) {
// If the servlet mod time is later, call doGet()
// Round down to the nearest second for a proper compare
// A ifModifiedSince of -1 will always be less
maybeSetLastModified(resp, lastModified);
resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
} else if (method.equals(METHOD_HEAD)) {
long lastModified = getLastModified(req);
maybeSetLastModified(resp, lastModified);
} else if (method.equals(METHOD_POST)) {
} else if (method.equals(METHOD_PUT)) {
} else if (method.equals(METHOD_DELETE)) {
} else if (method.equals(METHOD_OPTIONS)) {
} else if (method.equals(METHOD_TRACE)) {
String errMsg = lStrings.getString("http.method_not_implemented");
Object[] errArgs = new Object[1];
errMsg = MessageFormat.format(errMsg, errArgs);
resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, errMsg);