• 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

which method will invoke? doGet() or doPost()

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can you please tell me which method will invoke in the below senario?

what happens if i submit a form without mentioning the method type(get or post) and in called servlet if i have only doPost() method; will doPost() method execute?
 
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you don't specify a method type, by default it is a GET request, and if you have only doPost(), it doesn't get called, an HTTP status 405 is returned..

P:S: Why can't you try this yourself, instead of waiting for someone to give an answer for you?
 
Greenhorn
Posts: 7
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By default its GET , its always better to create a service method and call that inside doGet and doPost if your are planning to use both

Regards,
Jana
 
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

Janarthanan Rajendran wrote:its always better to create a service method and call that inside doGet and doPost if your are planning to use both


No it is not. GET and POST should do different things. It's very short-sighted and a violation of the HTTP contract to just have them to the same thing.
 
Nagaraj Shivaklara
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK,

Then can you please tell me which method will invoke if i have only doPost method in servlet and did not mention any method type in the form submission?


Bear Bibeault wrote:

Janarthanan Rajendran wrote:its always better to create a service method and call that inside doGet and doPost if your are planning to use both


No it is not. GET and POST should do different things. It's very short-sighted and a violation of the HTTP contract to just have them to the same thing.

 
Bear Bibeault
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
In your extending class? None. The base class will return a 405 error.
 
reply
    Bookmark Topic Watch Topic
  • New Topic