Tuesday, 28 June 2016

How to use RequestDispatcher to include or forward to a web resource ?


ServletContext.getRequestDispatcher(String path)
  • A RequestDispatcher object can be used to forward a request to the resource or to include the resource in a response.
  • The resource can be dynamic or static.
  • The path must begin with a "/" and is interpreted as relative to the current context root.

ServletRequest.getRequestDispatcher(String path)
  • The pathname specified may be relative, although it cannot extend outside the current servlet context.
  • If the path begins with a "/" it is interpreted as relative to the current context root.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.