Preface: The doGet and doPost methods are related to the way of passing parameters.
1. Introduction:
The doGet and doPost methods implement the methods in HttpServlet, doGet is used to process Get requests, and doPost is used to process Post requests. When the client sends a request, it calls the service method of the servlet and passes a request and response object. The service determines whether the request is a get request or a post request, and then calls the doGet method or the doPost method.
2. Processing source:
get method:
(1) Client input URL address
(2) url jump
(3) Submit form form get method
post method:
(1) The form form is submitted by post
Third, the difference between the two:
1. get is to obtain data from the server, and post is to transmit data to the server.
2. The amount of data transmitted by the get method is small, the security is not high, and the execution efficiency is high. It is suitable for data with low confidentiality such as search. The amount of data transmitted by the post method is large, the security is high, and the execution efficiency is low. Account password, modify, delete and add information transmission.
3. Get method: The form data is stored behind the URL address, and there is no message body in HTTP when all get methods are submitted.