读书笔记Review: HTTP and HttpServletRequest

  1. The HttpServlet's doGet() and doPost() methods take an HttpServletRequest and an HttpServletResponse.
  2. The service() method determines whether doGet() or doPost() runs base on the HTTP Method(GET,POST,etc.) of the HTTP request.
  3. POST requests have a body;GET requests do not,althogh GET requests can have request parameters appended to the request URL(sometimes called "the query string").
  4. GET requests inherently(according to the HTTP spec) idempotent.They should be able to run multipe times without causing any side effects on the server.GET requests shouldn't chanage anything on the server.But you could write a bad,no-idempotent doGet() method.
  5. POST is inherently not idempotent,so it's up to you to design and code your app in such a way that if the client sends a request twice by mistake,you can handle it.
  6. If an HTML from does not explicitly say "method=POST",the request is sent as a GET,not a POST.If you do not have doGet() in your servlet,the request will fail.
  7. You can get parameters from the request with the getParameter('paramname") method.The return value is always a String.
  8. You can get other things from the request object including headers,cookies,a session,the query string,and an input stream.
原文地址:https://www.cnblogs.com/yql1986/p/2001379.html