Multiple choice technology web technology

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

sendRedirect(String url) is the correct method on HttpServletResponse to redirect the client to a different URL. This sends a temporary redirect (HTTP 302) to the browser. getRequestDispatcher() is for server-side forwards, not redirects.