Context Object with RequestDispatcher |
Request Object With RequestDispatcher |
1. Using Context object with the getRequestDispatcher() its mandatory to write url starting with " / " . |
1. Using Request object with the getRequestDispatcher(), its not mandatory to use " / " before url.
|
2. It uses the context path of the URI.
|
2. It uses the context path if we write " / " before url and if we are not writing " / " then the request will be forwarded using relative path. |
3. If we are not writing " / " before
url then container will throw IllegalArgumentException exception " This given path is invalid, since it doesn't start with / " . |
3. If we are not writing " / " before url then it forward the request using relative path. |
4. For ex-
RequestDispatcher rd = getServletContext(). getRequestDispatcher("/url"); |
4. For ex- RequestDispatcher rd = getServletContext(). getRequestDispatcher("/url"); or RequestDispatcher rd = getServletContext(). getRequestDispatcher("url") ; |
Monday, 9 December 2013
Difference between using Context Object and Request Object with the RequestDispatcher
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment