![]() |
JBridge: Certification Question Of The Day |
| JBridge Home >> Certification Questions >> Question for Friday 16th May 2003 | Friday 16th May 2003 |
|
Given the following servlet code, identify what will happen when a HEAD request is made to the servlet's URL. (1 correct answer)
11 public class TestHeadRequest extends HttpServlet {
12 protected void doGet(HttpServletRequest request, HttpServletResponse
13 response) throws ServletException, IOException {
14 System.out.println("In TestHeadRequest");
15 PrintWriter out = response.getWriter();
16 out.write("Method Executed");
17 }
18 }
A "In TestHeadRequest" is output to the console. B "In TestHeadRequest" is output to the console and "Method Executed" is returned in the response body. C Nothing is output to the console or returned to the response body. D An HTTP response code 405 (Method Not Allowed) is returned to the requester. E Line 16 does not execute. Page down for the answer... The AnswerThe correct answer is A, "In TestHeadRequest" is returned to the console. When the doHead() method from the parent servlet is not overridden, and the servlet receives a HEAD request, the doGet() method is executed. |
EMail: dbridgewater@jbridge.co.uk
Phone: +44 (0)1943 877414
Fax: +44 (0)1943 877414
Mail: David Bridgewater, Willow Dene, Bradford Road, Menston, Ilkley, West Yorkshire, LS29 6ED, UK
Copyright © 2003 David Bridgewater. All rights reserved.