doGet() processes incoming HTTP GET requests, and doPost() processes ... POST requests. There are also equivalent processing methods for PUT, DELTE, etc.
If you submit your form using GET (by default), doGet() called. If you send using POST, doPost() will be called this time. If you use only doPost() , but the form will use GET, the servlet container will throw an exception.
In many programs, the server doesnβt care if the request uses GET or POST, why one method simply delegates to another. This is actually bad practice, because these methods are essentially different from each other, but many textbooks write it like this (for better or for worse).
Tomasz Nurkiewicz
source share