Home > other >  What to do if HttpServletResponse.getWriter() throws an IOException?
What to do if HttpServletResponse.getWriter() throws an IOException?

Time:11-17

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?

CodePudding user response:

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");
  • Related