Multiple choice technology architecture

Which method of HttpServletResponse is used to redirect an Http request to another URL?

  1. sendURL()

  2. redirectURL()

  3. sendRedirect()

  4. getRequestDispatcher()

Reveal answer Fill a bubble to check yourself
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.