I am having trouble to grasp the concept of relative and
absolute paths associated with RequestDispatcher. Please
help.
The
Servlet API says that ServletRequest.getRequestDispatcher()
can take both relative path and absolute path. If the path
starts with a "/", it is interpreted as relative to the current
context root.
The same Servlet API also says that
ServletContext.getRequestDispatcher() must take a path that
begins with a "/", which is also intepreted as relative to the
current context root.
Furthermore, the API says that the difference between the above
two methods is that the former method can take a relative path.
NOW HERE IS MY CONFUSION: since both methods can take a path
that begins with a "/", apparently, a path that begin with a
"/" is treated as an ABSOLUTE path. If this is a case, why
such an absolute path "is interpreted as RELATIVE TO THE
CURRENT CONEXT ROOT"??? Can anyone give me an example of
how a relative path looks like? Thanks!