• 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

doPost method ?  RSS feed

 
Ranch Hand
Posts: 77
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I came across one mock question.
In JSP below mentioned statement is given


In "MyServlet" Servlet, doGet() and doPost() method is defined.
Then answer is saying that it will call doGet() method.
Explanation is given like this:
doPost is invalid value, so it will interprets it as GET and will call doGet() method.
Is this right?
I had selected answer "Server reports an error"

Thanks
Imran
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried this case and doGet method is called.

Amit
 
Imran Vohra
Ranch Hand
Posts: 77
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But, anybody clearify that is it vendor-specific or guaranteed by spec.

Thanks
Imran
 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I doubt that can be guaranteed by Spec .

This totally depends on the browser in use
 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

doPost is invalid value, so it will interprets it as GET and will call doGet() method.
Is this right?



Yes, default mechanism for Form submission if through GET, hence goGet() is called.

In case if we want doPost() to be called then we need to specify it in FORM tag parameters
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!