RequestDispatcher's getRequestDispatcher()

Chinmaya Chowdary

Ranch Hand

Posts: 434

posted 7 years ago

Hi, If we get RequestDispatcher object through HttpServletRequest object like, we are giving relative path. If we get RequestDispacher object through ServletContext object like, we must specify with '/'.

Can you please explain why we are using '/' incase of ServletContext's method getRequestDispatcher()? Thankyou.

If the path begins with a "/" it is interpreted as relative to the current context root.

. Eventhough if we are using "/" it is interpreting as relative path, as incase of, RequestDispatcher view=request.getRequestDispatcher("result.jsp") does. Then why we have to use "/"(anyway it is not going outside the current application)? Can you please explain? Thankyou.