what is the difference between writing our buisness login codings in Service method block and writing codings in doGet() method and doPost() method. which one is better to follow.
posted 11 years ago
The basic rule is that you should never write code in the "service" method unless you are radically changing the way HTML behaves. A "service" method is provided for you by the servlet container, which does a lot of clever work deciding whether the request is GET, PUT, HEAD, OPTIONS and so on. You should never need to mess with this in normal servlet application programming. On the other hand, you don't want to duplicate your code in both the doGet and doPost methods, so what most of us do is something like the following:
This way you ensure that you write your code only once, and it will only be called for ordinary GET and POST requests, and not for any of the other wierd ones.