Which method(s) of RegisterServlet will be called when the user clicks on "Submit" button for the following form. Assume that RegisterServlet does not override the service() method of HttpServlet class. <html> <body> <form action="/RegisterServlet"> <input type="text" name="method" value="POST"> <input type="text" name="name"> <input type="password" name="password"> <input type="submit" value="POST"> </form> </body> </html>
Select 1 correct option.
1 servicePost(HttpRequest, HttpResponse);
2 doPOST(HttpRequest, HttpResponse);
3 doPost(HttpRequest, HttpResponse);
4 None of the above.
I think doGet() will be called. so answer should be 4 but answer is 3...some one too feels the same???/
Hi, When you use a HTTP form to submit info to server, doPost() must be called. doGet() is called when you either type URL in browser address bar, or click a hyperlink, or submit HTTP form with method="GET".
You are right, GET is the default method used on an HTML form. Since it isn't specified, This will cause the doGet method of the Servlet to be called. The other instances of the word POST in the text element and the submit element have to do with what those elements display and not what method will be used. so, the answer would have to be 4.
I would agree with Carl. The "POST" mentioned in other places do not mean anything. The first textbox will be named "method" and will have a default value "POST" showing on the textbox. The second textbox will be named "name" and will not have anything by default. The password textbox will be named "password" and will not show anything. The submit button will contain the string "POST" in its button. Since a name is not specified, I don't know what name it will choose. The HTTP spec. says that if there is no method attribute in a FORM element, then GET will be used by default. As there is not doGet() or service() in the answers, I would go with 4.