Here is my try-catch block:
try {
return dbConnection.createStatement();
} catch(SQLException sqle) {
// TODO SQL Exception
System.out.println(sqle.getMessage());
}
Is it correct to use System.out object in Servlets?
What is the easiest way for debugging purposes?
I wanted the message to be printed in the error page generated by the server, eg: HTTP Status 500.
It is not correct to use System.out in the servlet. One option is to simply forward to an error page using your RequestDispatcher:
In addition you can store the exception object in the request scope before forwarding to the error page so that the error is customized.
Then on error.jsp you can take that exception and print out some details.