| Author |
clarifying path for Redirect & Dispatcher
|
Selvaraj Subramanian
Ranch Hand
Joined: Jul 15, 2005
Posts: 37
|
|
Hi All, Correct me if I am wrong... As per my understanding (using Tomcat), sendRedirect() ============== 1)the path can be relative or absolute(htt://www.javaranch.com) 2)if its relative path & does NOT start with "/" then its considered as relative to the current URL path. 3)if its relative path starts with "/" then its considered as relative to the CONTAINER root. RequestDispatcher obtained from request object ============================================== 1)can accept only relative path 2)the path CAN start with or with out "/" 3)the path is considered as relative to the current URL path RequestDispatcher obtained from context object =============================================== 1)can accept only relative path 2)the path SHOULD start with "/" 3)the path is considered as relative to the current URL path am I correct?
|
Selvaraj.S<br />SCJP 1.4 -83%<br />SCWCD 1.4 - 85%<br />SCEA 4 Part 1(310-051) - 89%
|
 |
sarang bharambe
Ranch Hand
Joined: Apr 01, 2005
Posts: 40
|
|
Dear Selva, You are Correct as far as sendRedirect() is considered. But
RequestDispatcher obtained from request object ============================================== 1)can accept only relative path 2)the path CAN start with or with out "/" 3)the path is considered as relative to the current URL path
1. Can accept relative or absolute path 2. Correct 3. It should depend on whether the path is relative or not
RequestDispatcher obtained from context object =============================================== 1)can accept only relative path 2)the path SHOULD start with "/" 3)the path is considered as relative to the current URL path
The pathname must begin with a "/" ie absolute and is interpreted as relative to the current context root. Hope this clarifies the thing. Regards, sarang bharambe
|
SCJP 1.4 (86%)<br />SCWCD 1.4 (86%)<br />----------<br />If You dont succeed at first time,call it Version 1.0 !!!
|
 |
Gaurav Gambhir
Ranch Hand
Joined: Mar 04, 2006
Posts: 252
|
|
sendRedirect() ============== 1)the path can be relative or absolute(htt://www.javaranch.com) --Right 2)if its relative path & does NOT start with "/" then its considered as relative to the current URL path. -- Right 3)if its relative path starts with "/" then its considered as relative to the CONTAINER root.--Right RequestDispatcher obtained from request object ============================================== 1)can accept only relative path --Right 2)the path CAN start with or with out "/" -- Right 3)the path is considered as relative to the current URL path--Right RequestDispatcher obtained from context object =============================================== 1)can accept only relative path -- Right 2)the path SHOULD start with "/" --Right 3)the path is considered as relative to the current URL path--No This path must be relative to the root of the ServletContext Reference
|
 |
Selvaraj Subramanian
Ranch Hand
Joined: Jul 15, 2005
Posts: 37
|
|
Thanks Sarang Bharambe and Gaurav Gambhir... I agree with Gambhir, the relative path is considered as relative to the context. Sarang, the path we specify in requestDispatcher is relative path only. From Spec ========== The getRequestDispatcher method takes aString argument describing a path with in thes cope of the ServletContext. <b>This path must be relative</b> to the root of the ServletContext and begin with a �/'. [ June 16, 2006: Message edited by: Selvaraj Subramanian ]
|
 |
 |
|
|
subject: clarifying path for Redirect & Dispatcher
|
|
|