This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi, I want to display a customized Exception message from JRun Server whenever an exception occurs. I don't want to print the printStack on browser window. throw new ServletException(msg) prints stackTrace. I created my own Exception Class which extends the ServletException. Then i coded throw new MyException(msg) still it prints stackTrace. Please share your ideas Thanks Bin
What you'd need to do is catch the exception, customized or not, and do not let your Servlet emit this exception. Because you are not actually letting the Exception make it to the servlet runner (in your case JRun), it doesn't produce one of those standardized error pages.
When you catch the exception, place the exception into the attribute space, and redirect (or forward, whichever makes more sense), to an error page.
This way, it looks 'normal' to the servlet runner, and on your error page, you have the choice of displaying the stack trace in white writing on a white background, or as an HTML comment, or not at all.
Joined: Mar 17, 2001
Thanks Mike a lot Got it
subject: Throwing Customised Exception from Servlet (JRUN)