• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet runtime exceptions

 
Al Coholic
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

IMO, it would have to be a

Any other thoughts.
regds.
- satya
ps: I read your stmt abt try/catch not an option.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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.
Bill
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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 http://www.javaranch.com/name.jsp . 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.
Thanks.
 
Thomas Mcfarrow
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic