• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EPractice Lab mock exam 3 about request dispatcher forward 's url path.

 
Himai Minh
Ranch Hand
Posts: 1360
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The code snippet to access FrameworkViewSelector in controller is given below:
FrameworkViewSelector selector = FrameworkViewSelectorIml.getInstance();
String nextJSP = selector.getNextPage(request, FrameworkViewSelector.SUCCESS);
Next, the Front Controller servlet must send the request to nextJSP to generate the view.
Assume that the servlet variable request is assigned the current HttpServletRequest object and variable context is assigned
the webapp's ServletContext.
A. Dispatcher rd= context.getDispatcher(nextJSP);
rd.forwardRequest(request, response);

B. Dispatcher rd= request.getDispatcher(nextJSP);
rd.forwardRequest(request, response);

C. RequestDispatcher rd= context.getRequestDispatcher(nextJSP);
rd.forward(request, response);

D. RequestDispatcher rd = request.getRequestDispatcher(nextJSP);
rd.forward(request, response);

Given answer : D

I think the answer can be C as well even though only one option can be chosen.
The question does not say nextJSP starts with "/" or not.
If nextJSP starts with a "/", that means it is a relative path to the context .
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2531
112
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic