• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

just use doget()  RSS feed

 
Ranch Hand
Posts: 46
  • 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??
 
Sheriff
Posts: 23866
50
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.
 
Saloon Keeper
Posts: 5025
134
  • 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.
 
Marshal
Posts: 67162
169
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!