Please anyone help me regarding when and where to use relative path and when absolute path.There has been so much confusion regarding it.I think that I am not clear with relative path and absolute path even.Please anbody clear the difference and tell me where to use what like in forward(), in include(),in sendRedirect() and other places?
we use absolute path to access resources on a different web application in different web server( so sessions and other working environment like request attributes will not be available there).
we use relative path to access resources for applications hosted on same serve. further we can specify context relative or page relative path. A context relative path belongs to another application on same server(foreign context) and page relative path refers to path which current requested page belongs to(same context).
The getRequestDispatcher(String path) method of javax.servlet.ServletRequest interface accepts parameter the path to the resource to be included or forwarded to, which can be relative to the request of the calling servlet. If the path begins with a "/" it is interpreted as relative to the current context root.
The getRequestDispatcher(String path) method of javax.servlet.ServletContext interface cannot accepts relative paths. All path must sart with a "/" and are interpreted as relative to curent context root.