What is the benefit of using the servletContext as opposed the request in order to obtain a requestDispatcher?
servletContext.getRequestDispatcher(dispatchPath)
and using
argRequest.getRequestDispatcher(dispatchPath)
What is the benefit of using the servletContext as opposed the request in order to obtain a requestDispatcher?
servletContext.getRequestDispatcher(dispatchPath)
and using
argRequest.getRequestDispatcher(dispatchPath)
It's there in the javadocs in black and white
http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html#getRequestDispatcher(java.lang.String)
The difference between this method and ServletContext.getRequestDispatcher(java.lang.String) is that this method can take a relative path.
when we have to call getRequestDispatcher from ServletContext, we need to provide Absolute path but for ServletRequest object we need to provide relative path.