Multiple choice technology security

What method is provided within the security API to prevent caching by browsers and proxies?

  1. void setNoCacheHeaders(javax.servlet.http.HttpServletResponse response)

  2. void setNoCacheHeaders(javax.servlet.http.HttpServletRequest request)

  3. boolean setNoCacheHeader(javax.servlet.http.HttpServletResponse response)

  4. void setNoCacheHeaders(javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Cache control headers must be set on the HttpServletResponse object, not the HttpServletRequest. The method returns void as it performs an action (setting headers) rather than returning a value. ServletException is not relevant to header operations, making option A the correct signature.

AI explanation

To stop sensitive pages from being cached by browsers or intermediate proxies, the utility method operates on the outgoing HttpServletResponse and sets headers like Cache-Control: no-cache, Pragma: no-cache, and Expires. It can't act on the HttpServletRequest since that represents the incoming request, and the method is a void action rather than something that returns a boolean or declares a checked exception.