读书笔记-Review: HTTP and HttpServletRequest
- The HttpServlet's doGet() and doPost() methods take an HttpServletRequest and an HttpServletResponse.
- The service() method determines whether doGet() or doPost() runs base on the HTTP Method(GET,POST,etc.) of the HTTP request.
- 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").
- 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.
- 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.
- 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.
- You can get parameters from the request with the getParameter('paramname") method.The return value is always a String.
- You can get other things from the request object including headers,cookies,a session,the query string,and an input stream.