I am writing a servlet, in that if any exception occurs i donэt want to display exception/error message on browser, so I will redirect to my customized error page. So I have
In some method, you would have the following:
try {
// something
} catch (Exception e) {
sendErrorRedirect(req, res, "/errorpage.jsp", e);
}
// then.... sendErrorRedirect looks like this:
protected void sendErrorRedirect(HttpServletRequest request, HttpServletResponse response, String errorPageURL, Throwable e) {
try {
request.setAttribute ("javax.servlet.jsp.jspException", e);
getServletConfig().getServletContext().getRequestDispatcher(errorPageURL).forward(request, response);
} catch (Exception ex) {
putError("serXXXXX.sendErrorRedirect ", ex);
}
}