This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doPost method ?

 
Imran Vohra
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
 
Amit Tayal
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
 
Vikrant Pandit
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
 
Mohd Fuzail
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic