There are two use cases:
1.response.getWriter().print("");
2.PrintWriter out = response.getWriter();
out.print("");
out.close();
Do I always need to close the Writer like showing in the second case? or can I do it as simple as the first one?
There are two use cases:
1.response.getWriter().print("");
2.PrintWriter out = response.getWriter();
out.print("");
out.close();
Do I always need to close the Writer like showing in the second case? or can I do it as simple as the first one?
You get writer from response so normally you should not call close() while doing this. The servlet container will close for you.
If you pre-close your writer here, some feature will not work.
For example, your Filter may throw exceptions that IllegalStateException: the output stream has already been closed