If i have overridden doGet() only in my
servlet and a request comes for doHead() then does it throw an error or executes doGet()?
Given the following servlet code, identify what will happen when a HEAD request is made to the servlet's URL.
[CODE:
JAVA NUM]
public class TestHeadRequest extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
System.out.println("In TestHeadRequest");
PrintWriter out = response.getWriter();
out.write("Method Executed");
}
}
[/CODE:JAVA]
Possible Answer(s)
- "In TestHeadRequest" is output to the console.
- "In TestHeadRequest" is output to the console and "Method Executed" is returned in the response body.
- Nothing is output to the console or returned to the response body.
- An HTTP response code 405 (Method Not Allowed) is returned to the requester.
- Line 16 does not execute.
Correct Answers "In TestHeadRequest" is output to the console.