Which of the following sends an error message to client?
-
sendErrorMessage()
-
sendError()
-
sendMessage()
-
sendHttpErrorCode()
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.