Assuming that request is the ServletRequest object and context is the ServletContext object. Which of the following request dispatcher elements will correctly fetch the dispatcher to the "ControllerServlet" ?
The code is executed from the "RedirectServlet".
web.xml of "whiz" web application.
a) context.getRequestDispatcher("/whiz/ControllerServlet"); b) request.getRequestDispatcher("ControllerServlet"); c) request.getRequestDispatcher("/whiz/ControllerServlet"); d) context.getRequestDispatcher("/ControllerServlet"); e) context.getRequestDispatcher("ControllerServlet"); f) context.getNamedDispatcher("ControllerServlet"); g) context.getNamedDispatcher("/ControllerServlet"); h) request.getNamedDispatcher("/ControllerServlet");
I chose options D and F but according to WhizLabs the correct options are B, D and F.
Why B is correct ? Once the request is executed from the /Redirect path, requesting such dispatcher I would get a /Redirect/ControllerServlet which is not mapped in DD, right ?
Did I forget anything ?
Oh, can <servlet-name> element come after the <servlet-class> element ? I thought it was the opposite.
"If someone asks you to do something you don't know how to, don't tell I don't know, tell I can learn instead." - Myself