doGet and doPost simple to understand

and post are two ways to get http protocol

These two methods are essentially different, get only one stream parameters appended to the url, the number of sizes are strictly limited and only a string. Post parameters are passed by an additional flow, not through url, can be large, you may pass binary data, such as file uploads.

 

  1. doGet

GET call used to get server information, and returns it to the client as a response. When via a Web browser or through HTML, JSP Servlet direct access to the URL, usually with GET call. GET call is being passed in the URL Servlet display of data, which may cause some problems in terms of security of the system. For example, users log in, in the form of user name and password to be sent to the server side, if you use the Get call, it will display the user name and password in the URL in the browser.

  1. doPost

POST and GET action, are acquired server information, and as a response back to the client, the advantage is that you can hide any data to the server. Post suitable for sending large amounts of data. (But there are drawbacks)

        

method:

         That will call the doPost method doGet in writing , so no matter the browser sends a GET request or a POST request, it can be responded to. For chestnuts

 

         public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException {

       doPost(request,response);

    }

   

    public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException {

       response.getWriter().write("hello world!");

  }

Guess you like

Origin www.cnblogs.com/waibizi/p/11576247.html