Servlet-doget () and dopost () for Java Learning ()

Source: Internet
Author: User
The Serlvet interface defines only one service method as service, while the httpservlet class implements this method and requires that one of the following methods be called:
Doget: Process GET requests
Dopost: Process post requests
When sending a client request, call the service method and pass a request and response object. Servlet first checks whether the request is a get operation or a post operation. Then it calls the following method: doget or dopost. If the request is get, the doget method is called. If the request is Post, The dopost method is called. Both doget and dopost accept requests (httpservletrequest) and responses (httpservletresponse ).

So,

Doget is called when receiving a webpage using the get Method
Dopost is used to receive the POST method.
The get method is like a bunch of garbled characters you see in the address bar of the webpage, that is, parameters are added to the URL.
Post is passed through the form, as if to package all the data and send it to the past.
If you don't know what method to use, you can write all the functions together in the servlet.
Then you can call another method in one method.
For example
Public void dopost (httpservletrequest request, httpservletresponse)
Throws servletexception, ioexception
{
Doget (request, response );
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.