What method is provided within the security API to prevent caching by browsers and proxies?
-
void setNoCacheHeaders(javax.servlet.http.HttpServletResponse response)
-
void setNoCacheHeaders(javax.servlet.http.HttpServletRequest request)
-
boolean setNoCacheHeader(javax.servlet.http.HttpServletResponse response)
-
void setNoCacheHeaders(javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException
The correct method signature uses HttpServletResponse as the parameter since caching headers are set on the response object. The method is void because it performs an action (setting headers) rather than returning a value. Option B incorrectly uses HttpServletRequest, and options C and D have incorrect return types or exception declarations.
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, not the response being sent back, and the method is a void action rather than something that returns a boolean or declares a checked exception.