You want to use URL rewriting to support client browsers, which do not use cookies. Which method will you use to attach the session id to a URL that is to be used for the sendRedirect() method of the HttpServletResponse?

  1. encodeURL

  2. encodeRedirectURL

  3. encodeSessionURL

  4. encodeSessionRedirectURL

  5. None of these


Correct Option: B

AI Explanation

To attach the session ID to a URL that is to be used for the sendRedirect() method of the HttpServletResponse, you can use the encodeRedirectURL method.

The correct answer is B) encodeRedirectURL.

Explanation for each option:

A) encodeURL - This method is used to encode the URL, including the session ID, if necessary. However, when using the sendRedirect() method, encodeRedirectURL should be used instead.

B) encodeRedirectURL - This method is used to encode the URL, including the session ID, if necessary, specifically for the sendRedirect() method.

C) encodeSessionURL - This method does not exist in the HttpServletResponse class.

D) encodeSessionRedirectURL - This method does not exist in the HttpServletResponse class.

E) None of these - The correct answer is B) encodeRedirectURL.

Therefore, the correct answer is B) encodeRedirectURL.

Find more quizzes: