• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlets

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic