aspose file tools*
The moose likes Servlets and the fly likes Throwing Customised Exception from Servlet (JRUN) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Throwing Customised Exception from Servlet (JRUN)" Watch "Throwing Customised Exception from Servlet (JRUN)" New topic
Author

Throwing Customised Exception from Servlet (JRUN)

Sarath Mohan
Ranch Hand

Joined: Mar 17, 2001
Posts: 213
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


Sarath Mohan
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

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.
Sarath Mohan
Ranch Hand

Joined: Mar 17, 2001
Posts: 213
Thanks Mike a lot
Got it
 
Don't get me started about those stupid light bulbs.
 
subject: Throwing Customised Exception from Servlet (JRUN)
 
Similar Threads
How to avoid client dependencies on classes of an Exception's cause?
Problem when get all the exception stacktrace
Standard way to handle null getRequestDispatcher()?
Throwing more than one application exception from a ejb interface
How to capture the exceptions thrown from third party services in servlet