• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

just use doget()

 
eugene malcolumn
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when we make a servlet in eclipse it makes doget() and dopost() only. isnt its necessary to use service() in a servlet??
 
Paul Clapham
Sheriff
Posts: 21583
33
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. Using the service() method is bad practice. If you want your servlet to respond to GET requests then you should implement the doGet() method, and if you want it to respond to POST requests then you should implement the doPost() method. That's what those two methods are for, so just using service() is sloppy.
 
Tim Moores
Bartender
Posts: 3137
50
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It also violates the HTTP specification which states that GET and POST serve different purposes and should not be used interchangeably. Certain IDEs (NetBeans in particular) proliferate this bad practice by generating boilerplate code that makes it seem as if both are identical - very much not so.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65342
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And it's doGet(), not doget(). Case matters.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic