| Author |
dispatching requests
|
Ken Sampson
Ranch Hand
Joined: Sep 26, 2007
Posts: 45
|
|
Hello, I have 2 servlets called TestServlet1 and TestServlet2. In the first servlet, I write either of the following statements that would forward the page to TestServlet2. RequestDispatcher dispatch = request.getRequestDiaspatcher("TestServlet2"); and RequestDispatcher dispatch = request.getRequestDiaspatcher("/TestServlet2"); Could you please tell me if there is any difference between the above statements. Does that slash ("/") make any difference to anything?
|
Ken Sampson
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14669
|
|
A path beginning with "/" is relative to the application context, whereas a path not beginning with "/" is relative to the current request. Application : /myapp Request : /myapp/registerUser If you forward to "/home", the request will map to "/myapp/home". If you forward to "home", the request will map to "myapp/registerUser/home".
|
[My Blog]
All roads lead to JavaRanch
|
 |
 |
|
|
subject: dispatching requests
|
|
|