A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Joined: Sep 26, 2007
Apr 08, 2008 23:28:00
I have 2
called TestServlet1 and TestServlet2.
In the first
, I write either of the following statements that would forward the page to TestServlet2.
dispatch = request.getRequestDiaspatcher("TestServlet2");
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?
Joined: Nov 24, 2005
Apr 09, 2008 00:05:00
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".
All roads lead to JavaRanch
subject: dispatching requests
Call servlet from java class and redirect to jsp page
What is the difference between requestdispatcher and sendredirect?
fill and anchor
Jsp under WEB-INF
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014