A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Murach's Java Servlets and JSP
this week in the
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
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
subject: dispatching requests
Jsp under WEB-INF
fill and anchor
What is the difference between requestdispatcher and sendredirect?
Call servlet from java class and redirect to jsp page
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014