Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

doPost query

 
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
 
Rancher
Posts: 43016
76
  • 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: 43016
76
  • 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.
 
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 !!!
 
I've been selected to go to the moon! All thanks to this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic