Multiple choice general knowledge science & technology

Which of the following sends an error message to client?

  1. sendErrorMessage()

  2. sendError()

  3. sendMessage()

  4. sendHttpErrorCode()

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

The HttpServletResponse.sendError() method sends an error response to the client with a specific HTTP status code. Methods like sendErrorMessage(), sendMessage(), and sendHttpErrorCode() don't exist in the servlet API. sendError() is the standard way to send error responses.