Which method of HttpServletResponse is used to redirect an Http request to another URL?
-
sendURL()
-
redirectURL()
-
sendRedirect()
-
getRequestDispatcher()
C
Correct answer
Explanation
HttpServletResponse.sendRedirect(String URL) is the standard method to redirect the client to a different URL. This sends a 302 temporary redirect response to the browser, which then makes a new request to the target URL. Options A and B are non-existent methods. Option D (getRequestDispatcher) is for server-side forwarding/dispatching, not client-side redirection - it forwards the request without the client knowing.