Which code snippet of the Front Controller servlet accomplishes this goal?

Your IT department is building a lightweight Front Controller servlet that invokes an application
logic object with the interface:
public interface ApplicationController {
public String invoke(HttpServletRequest request)
}
The return value of this method indicates a symbolic name of the next view. From this name, the
Front Controller servlet looks up the JSP URL in a configuration table. This URL might be an
absolute path or a path relative to the current request. Next, the Front Controller servlet must send
the request to this JSP to generate the view. Assume that the servlet variable request is assigned
the current HttpServletRequest object and the variable context is assigned the webapp’s
ServletContext.
Which code snippet of the Front Controller servlet accomplishes this goal?

Your IT department is building a lightweight Front Controller servlet that invokes an application
logic object with the interface:
public interface ApplicationController {
public String invoke(HttpServletRequest request)
}
The return value of this method indicates a symbolic name of the next view. From this name, the
Front Controller servlet looks up the JSP URL in a configuration table. This URL might be an
absolute path or a path relative to the current request. Next, the Front Controller servlet must send
the request to this JSP to generate the view. Assume that the servlet variable request is assigned
the current HttpServletRequest object and the variable context is assigned the webapp’s
ServletContext.
Which code snippet of the Front Controller servlet accomplishes this goal?

A.
Dispatcher view
= context.getDispatcher(viewURL);
view.forwardRequest(request, response);

B.
Dispatcher view
= request.getDispatcher(viewURL);
view.forwardRequest(request, response);

C.
RequestDispatcher view
= context.getRequestDispatcher(viewURL);
view.forward(request, response);

D.
RequestDispatcher view
= request.getRequestDispatcher(viewURL);
view.forward(request, response);

Explanation:



Leave a Reply 1

Your email address will not be published. Required fields are marked *