What is sendRedirect()?

response.sendRedirect(String URL) makes the browser do the work. Its like asking the client to call the new URL instead. The browser again makes a new request to the URL(the argument of the method). A new request, response object is created. You can use relative URL as an argument instead of specifying the whole(www….).

The relative URL can be two types with foreward slash(“/”) and with foreward slash.
Suppose a URL
so it come to the URL
but if we write like this sendRedirect(“/foo/stuff.html”);
The foreward slash at the beginning means relative to the root of the web container itself instead of relative to the URL of the request.

No comments:

Post a Comment