Why write Try without a Catch or Finally as in the following example?
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
This is a new feature in Java 7 and beyond. Without this, you'd need a finally
block which closes the resource PrintWriter out
. So the code above is equivalent to:
PrintWriter out = null;
try {
PrintWriter out = ...
} finally {
if(null != out) {
try {
out.close();
} catch(Exception e) {} // silently ignore!
}
}
See The try-with-resources Statement