Issue
The function HttpServletResponse.getWriter() actually throws an IOException, when that happens, the ideal thing to do is send an 500 status in the response, is there a way to do that without a viable PrintWriter?
Solution
Yes you can,
You can do that via HttpServletResponse
using sendError()
function.
You can do something like this:
response.sendError(SC_INTERNAL_SERVER_ERROR, "your error message");
Answered By - Le Programmeur
Answer Checked By - Candace Johnson (JavaFixing Volunteer)