Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doPost query

 
geet rahane
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q from ' Free SCWCD Mock exam for Servlets By Nikos'
# Consider this form.


What is the output when the form is submitted? (1 correct answer)

1. GET
2. POST
3. A HTTP 405 message informs that GET is not supported.
4. A HTTP 405 message informs that POST is not supported.
answer is 4

I dont understand why the servlet had not call the doPost and then doGet ..and why we get A HTTP 405 message...please help....

Thanks in advance
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The signature of the doPost method is such that it does NOT override the doPost method in the HttpServlet class. Hence, a 405 (the default action of the HttpServlet's doPost method.)
 
geet rahane
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so if the signature get changed to protected void then that doPost get call right??

please correct if i'm wrong
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, methods defined in interfaces always need to be public.

Have a closer look at the parameters. This is a good example of why the "@Override" annotation is so useful.
 
Lorenz Baylon
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah tricky stuff.. this just gave me a tip to look closer to the questions when I take the exam.
 
geet rahane
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks !!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic