• 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

Diference doGET doPost and processRequest

 
Ranch Hand
Posts: 1402
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

is service method like processRequest method?

Is it work in the same way?

Regards, Isaac
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. In fact, the "processRequest pattern" is an anti-pattern where both GET and POST are treated the same way in the servlet. Bad bad practice.

GET and POST should not do the same thing according to the intentions of the HTTP protocol.

While there is a lot to write on the distinction, the stratospheric view is that GET is for getting resources, while POST is for posting operations. That just scratches the surface but shows how treating GET and POST as the same operation is just flat-out wrong.

Caveat: it's a very common mistake and I used to make this poor mistake myself. I now know better.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see you changed your post while I was writing, so my answer doesn't match your new question as well as the former. Please don't do that.

And no, a processRequest is not like service. service is a method in the container that eventually calls on of doGet or doPost. The processRequest is an anti-patterm where the doGet and doPost methods call it, completely losing the distinction between them.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And, to make sure that there is no confusion; the processRequest method is not part of the servlet standard but is a method added by some IDEs. It is not something that should ever be used.
 
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, another NetBeans user. Bear is correct of course, this is a terrible pattern. I suggest you modify the servlet template. Go to Tools - Templates and then down to Web - Servlet. Choose Open in Editor. My template looks like this. The license section and the getServletInfo() section are optional.

 
reply
    Bookmark Topic Watch Topic
  • New Topic