• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Use relative URL for RequestDispatcher

 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On p. 146 of Charles Lyon's book,

Which methods on which interfaces can be used to obtain a RequestDispatcher for a relative URL? (choose two)
...
B. getRequestDispatcher(String) on ServletContext
..
D.getRequestDispatcher(String) on ServletRequest
E.getRequestDispatcher(String) on HttpServletRequest


I think there should be three answers : B,D,E.
But the given answers are only D,E.

According to ServletContext API, the ServletContext.getRequestDispatcher(url).

ServletContext "
The pathname must begin with a / and is interpreted as relative to the current context root


 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2536
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The pathname must begin with a / and is interpreted as relative to the current context root

This is relative to the current context root but not relative to the current Servlet (from where the requestDispatcher is gotten). That is why B is not correct.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic