Only 49 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

doGet() and service() method  RSS feed

 
Arun Maalik
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all i have written two code in servlet as



Another code is


Both working fine code 1st having doGet() method while code 2nd having service() method then what is diffrence between them.

Regard
Arun
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By using doGet, doPost, or any of the other do___ methods you enable your servlet respond to different types of requests in different ways.

The default service method figures out which type of request has been made and delegates to the proper do___ method. Once you override it, you've erased that capability.

A simple rule of thumb is never to override the service method.
If you want post and get requests to behave the same have one call the other.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some more information is available in this FAQ entry.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!