| Author |
2 ways of getting a RequestDispatcher
|
Rajiv Chelsea
Ranch Hand
Joined: Jun 15, 2010
Posts: 88
|
|
What is the difference between the getRequestDispatcher(String path) method of javax.servlet.ServletRequest interface and javax.servlet.ServletContext interface?
|
 |
Abimaran Kugathasan
Ranch Hand
Joined: Nov 04, 2009
Posts: 2066
|
|
|
If I correct, ServletContext's getRequestDispatcher(String path) method has the absolute path/url as argument!
|
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
|
 |
Rajiv Chelsea
Ranch Hand
Joined: Jun 15, 2010
Posts: 88
|
|
That's correct
Are there any advantages we get by getting requestDispatcher from
ServletContext?
|
 |
Sudipta Laha
Ranch Hand
Joined: Aug 23, 2010
Posts: 49
|
|
There is a method getContext(string) in servletContext which can be used to get the foreign context. so we can use the method getRequestDispatcher to get the RequestDispatcher for resources in foreign context. But when we use the request.gerRequestDiapatcher method we get the RequestDispatcher of the current context only.
So the servletContext requestDispatcher may be helpful in some scenarios.
|
Regards,
Sudipta Kumar Laha
|
 |
 |
|
|
subject: 2 ways of getting a RequestDispatcher
|
|
|