tags:

views:

101

answers:

2

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)
+2  A: 

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.

skaffman
A: 

when we have to call getRequestDispatcher from ServletContext, we need to provide Absolute path but for ServletRequest object we need to provide relative path.

kalyan