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

Form question

 
BJ Grau
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I encountered a question on a mock SCWCD exam that asked:
What HTTP method and corresponding HttpServlet method is used when a user clicks on "Submit" button of any standard Form displayed by a browser?
The answer given was :
POST and doPost(HttpServletRequest, HttpServletResponse)
I thought that all requests sent to a servlet invoked the service method, which then decided which doXXX method to invoke based on the type of the request.
[This message has been edited by BJ Grau (edited September 29, 2001).]
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you remember which exam and the exact question? Especially the exact answers available. My inclanation for the answer to this would be "GET" and "doGet" Html forms that do not supply a "method" attribute, use GET as the default or the "standard" method. However the wording of each of the answers could leave "POST" and "doPost" as the only possible choice.
The wording of the objective 1.1 "For each of the HTTP methods, GET, POST, and PUT, identify the corresponding method in the HttpServlet class" leaves out service. Especially when you look at the API and it states for the service method "There�s no need to override this method."
------------------
I Hope This Helps
Carl Trusiak, SCJP2
[This message has been edited by Carl Trusiak (edited September 30, 2001).]
 
Tim Duncan
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carl's right ... GET is the default method for a FORM, unless POST is specified explicitly.
Originally posted by BJ Grau:
I thought that all requests sent to a servlet invoked the service method, which then decided which doXXX method to invoke based on the type of the request.

True, but the question does ask which HTTP method and corresponding HttpServlet method, and of course service is not an HTTP method.
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3817
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am assuming this question is from JWebPlus. If you look at the explanation, it notes that although GET is the default method for a FORM but normally (in fact, almost always), POST is used. You might already know the reasons.
This sounds ambigous as the question does not say anything about the method used in the form, but it does say "standard" form.
I got a similar question in the exam and I interpreted "standard" as POST because that's what a form is normally used for. I think, it was marked correct.
HTH,
Paul.
------------------
SCJP2, SCWCD Resources, Free Question A Day, Mock Exam Results and More!
www.jdiscuss.com
Get Certified, Guaranteed!
JQPlus - For SCJP2
JWebPlus - For SCWCD
JDevPlus - For SCJD
 
BJ Grau
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys.
Yes Paul, it is JWebPlus.
I hope Sun is very clear with the questions asked when I take the exam.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic