The difference between Doget and DoPost in a servlet

Updated on technology 2024-04-06
17 answers
  1. Anonymous users2024-02-07

    Generally speaking, we don't use the doget method, the doget method is used by the servlet to submit header data, and the doget method will display the submitted content after the url when submitting the form, so it is not safe. And the doget method can only submit 256 characters. DoPost does not have this restriction.

    Usually we use the dopost method, and you just need to call each other in the servlet, e.g. in the doget method.

    public void doget(httpservletrequest request, httpservletresponse response)

    throws servletexception, ioexception {

    dopost(request,response);

    Then write the business logic directly in the dopost method. When a servlet encounters a doget method call, it will call dopost because they all have the same arguments. And the doget method is difficult to deal with Chinese problems, and you have to write filters and the like.

  2. Anonymous users2024-02-06

    The form can be written with method="get"Or method="post"

    get

    The URL displays:

    post

    The URL displays:

  3. Anonymous users2024-02-05

    Don't modify the servlet yourself, it's generated by the system itself.

  4. Anonymous users2024-02-04

    Doget and DoPost are actually used to receive data from the front-end, which are essentially request methods. This is because there are two types of requests: get and post. The get call, which is typically used to get server information and return it to the client as a response.

    That is, when the URL of the servlet is directly accessed through a web browser, HTML, or JSP, it is called. POST is used to send client-side data to the server, but there are drawbacks.

    When the server creates a servlet object, the servlet object initializes itself by calling the init method. In this new thread, the servlet object calls the service object to check the HTTP request type to determine whether the request type is get or post, and in the service method, call the doget and dopost methods according to the request type.

    1. Get request, the information transmitted by the page will be displayed in the form of key-value pairs behind the URL in the address bar to achieve the purpose of transmission.

    3. The GET request has a limit on the size of the submitted data, which is usually about 1024 bytes. Not used to submit big data.

    4. There is no limit on the size of the submitted data for POST requests.

  5. Anonymous users2024-02-03

    There are two kinds of http requests, one is the GET request, the other is the POST request, the doget() in the servlet is to handle the GET request, the GET request is to put the data to be transmitted in the address bar, which is limited and insecure. dopost() is used to handle POST requests, which are more secure and are not displayed in the address bar.

  6. Anonymous users2024-02-02

    In fact, the function of doget and doposted is the same, that is, to get the data passed from the previous stage. However, the data passed through method="get" will be displayed in the URL of the request. Method="post", the data will not be displayed in the requested URL.

  7. Anonymous users2024-02-01

    The doget() method is called when the client sends an HTTP request using the get method, and the dopost() method is called when the client sends an HTTP request using the post method, and the get request is used for form and address input, while POST is only used for form input.

    post Yes, the data is written to the server.

    get is passed to the server by passing parameters.

  8. Anonymous users2024-01-31

    One is a get submission and the other is a post submission, both of which call the dopost method in doget.

  9. Anonymous users2024-01-30

    Doget uploads have a size limit, and DoPost has no limit.

    One is safe, one is not.

  10. Anonymous users2024-01-29

    Two different requests, both are insecure, anyone who knows a little knowledge can see it, and the privacy of the post is slightly better!

  11. Anonymous users2024-01-28

    When the server creates a servlet object, the object will call the init method to initialize itself, and every time the server receives a servlet request, a new thread will be generated, in which the servlet object will call the service object to check the http request type (get, post), and call the doget and dopost methods according to the request type in the service method.

    If the server process is exactly the same regardless of whether the user request type is get or post, then you can just write the process in dopost and call dopost in doget, and vice versa, you can also process it in doget and call doget in dopost. If different processing is required depending on the type of request, you need to write different procedures in the two methods. The get request thing (the information you enter on the page) will be displayed in the address bar, so it's not safe, and the post won't be displayed, which will be a little better.

  12. Anonymous users2024-01-27

    The former one is displayed in the address bar, and the latter is no longer displayed in the address bar.

  13. Anonymous users2024-01-26

    doget is to process get requests from clients, and dopost is to handle post requests from clients, and their differences can be explained from the following 7 aspects:

    1. The way in which the client (generally refers to the browser) is generated.

    The method attribute in the post:form is post.

    2. Client data transmission mode.

    post: The form data is stored in the message body of the HTTP protocol and transmitted to the server in the form of an entity.

    3. How the server obtains data.

    get: The server uses the doget in the servlet to get the value of the variable;

    post: The server uses the dopost in the servlet to get the data.

    4. The amount of data transferred.

    post: suitable for large-scale data transfer. Because it's delivered in a physical way.

    5. Security.

    post:High security. Because the HTTP POST mechanism is used when submitting data in the POST mode, the fields in the form are placed in the HTTP header and sent to the URL referred to by the action, which is invisible to the user.

  14. Anonymous users2024-01-25

    There is no difference, but the method of HTML form submission is the adjustment of POST and the adjustment of GET to doget. In general, the processing is the same regardless of the method of submitting the form, so just write one and adjust it in the other. public void doget(httpsrevletrequest request, httpservletresponse response) public void dopost(httpsrevletrequest request, httpservletresponse response)

  15. Anonymous users2024-01-24

    It is just a call to doget in dopost, the protocol is different, but the implementation logic is the same, so you can call it directly.

    When the doget method submits the form, it will display the submitted content after the URL, so it is not safe. Moreover, the doget method can only submit 256 characters (1024 bytes), while the dopost has no limit, because the data transmission carrier in get mode is url (the submission method can be form, and it can also be linked to any url), and the post is the http header key-value pair (can only be submitted in form mode).

    Usually the dopost method is used, just let the two methods call each other in the servlet, for example in the doget method:

    public void doget(httpservletrequest request, httpservletresponse response)

    throws servletexception, ioexception {

    dopost(request,response);

  16. Anonymous users2024-01-23

    dopost and doget, the content of the method is the same.

    Therefore, calling each other can reduce the amount of **. If you want to modify **, you only need to modify one place, which is more convenient.

  17. Anonymous users2024-01-22

    Because there are two ways to request a foreground page:

    This request submitted to the background is the doget method.

    This request submitted to the background is the dopost method.

    The content in the two methods is the same, and the reason why it is called this way is to avoid reuse.

Related questions
8 answers2024-04-06

First, the focus is different.

1. Different with focuses on comparing with others >>>More

6 answers2024-04-06

2D is generally a plane, and 3D is three-dimensional, that is, three-dimensional.

7 answers2024-04-06

The dynamics are different, you can see it carefully when you play Immortal Hunting.

6 answers2024-04-06

It's not imaginary, it's just that when you zoom in to a certain size For example, 40 inches, D40 can't be so clear, but D40X can, the gap is in these 400W pixels!

1 answers2024-04-06

Hello! When choosing a DSLR digital camera, the first thing is to choose the brand, because the brand determines the update of your accessories and lenses in the future. The brands are naturally Nikon and Canon, and other brands do not need to be considered. >>>More