Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Servlets and the fly likes Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlets" Watch "Servlets" New topic
Author

Servlets

Gopinath Reddy
Greenhorn

Joined: Feb 26, 2004
Posts: 15
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.
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
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.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlets