首页 > 代码库 > servlet源码
servlet源码
[c-sharp] view plaincopy
- protected void service(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException
- {
- String method = req.getMethod();
- if(method.equals("GET"))
- {
- long lastModified = getLastModified(req);
- if(lastModified == -1L)
- {
- doGet(req, resp);
- } else
- {
- long ifModifiedSince = req.getDateHeader("If-Modified-Since");
- if(ifModifiedSince < (lastModified / 1000L) * 1000L)
- {
- maybeSetLastModified(resp, lastModified);
- doGet(req, resp);
- } else
- {
- resp.setStatus(304);
- }
- }
- } else
- if(method.equals("HEAD"))
- {
- long lastModified = getLastModified(req);
- maybeSetLastModified(resp, lastModified);
- doHead(req, resp);
- } else
- if(method.equals("POST"))
- doPost(req, resp);
- else
- if(method.equals("PUT"))
- doPut(req, resp);
- else
- if(method.equals("DELETE"))
- doDelete(req, resp);
- else
- if(method.equals("OPTIONS"))
- doOptions(req, resp);
- else
- if(method.equals("TRACE"))
- {
- doTrace(req, resp);
- } else
- {
- String errMsg = lStrings.getString("http.method_not_implemented");
- Object errArgs[] = new Object[1];
- errArgs[0] = method;
- errMsg = MessageFormat.format(errMsg, errArgs);
- resp.sendError(501, errMsg);
- }
- }
servlet源码
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。