File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Servlet runtime exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet runtime exceptions" Watch "Servlet runtime exceptions" New topic

Servlet runtime exceptions

Al Coholic

Joined: Jul 05, 2001
Posts: 1
Does anyone know of the servlet equilvalent to the JSP directive <%@ page errorpage = "someurl" %>? I need to catch any runtime exceptions any display a clean message.
Putting try/catch blocks is not an option. We have about 500-600 class files and a change this late will be too critical.
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

IMO, it would have to be a

Any other thoughts.
- satya
ps: I read your stmt abt try/catch not an option.

Take a Minute, Donate an Hour, Change a Life
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
"Putting try/catch blocks is not an option."
Well you are not going to catch exceptions any other way, but you only need to have try/catch at the servlet doGet - doPost level. I generally enclose practically all the code in doGet or doPost in a try/catch - be sure to log the result as well as try to write a HTML page with the exception stack trace.
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
"Al Coholic" ? A little too much Bart Simpson, I think,
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Obviously fake names are not appropriate in a professional community such as this. Please log in with a new name which meets the requirements.

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Thomas Mcfarrow
Ranch Hand

Joined: Jul 09, 2001
Posts: 137
According to the book "Core JSP" the <%@ page errorpage = "someurl" %> will deal with any uncaught exceptions.
"This allows the JSP author to deal with any uncaught expcetions and present a nice looking front-end page to the client"
This is how you would deal with exceptions without a try/catch clause.
Does anyone know if there is a servlet equivalant?
I agree. Here's the link:
subject: Servlet runtime exceptions
jQuery in Action, 3rd edition