These two methods acts as Service() method in servlet. In project we can use service() or doGet() or doPost(). Now let us see doGet() and doPost() in detail.
In the above figure you can see the login form. Since this is get() when we enter the username and password and click on Enter/Login button, both the username and password gets appended to the url as follows.
You can observe the username and password appended to the url. This is the major disadvantage of get() method. To overcome this we use Post().
doGet():
This method indicates which operation has to be carried out by the server. This is the default method sent by the client to the server. In get(), the data that client wants to send to server will get appended to url. But the url limits to 1024 characters. Let us see with example. When we type the url in the address bar and once if we press Enter, by default get request goes to the server.In the above figure you can see the login form. Since this is get() when we enter the username and password and click on Enter/Login button, both the username and password gets appended to the url as follows.
You can observe the username and password appended to the url. This is the major disadvantage of get() method. To overcome this we use Post().
No comments:
Post a Comment