• Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception Handling frame work

 
Ayub ali khan
Ranch Hand
Posts: 395
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can any one provide me some important points which needs to be considered while designing a frame work for Exception handling for a basic Web application.

Best Regards
Ayub.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not an advanced question. Moving...
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java and the servlet spec provide a fairly comprehensive framework for exception handling.

Why are you trying to build your own?
 
Alex Sotin
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly you want to know..? What do you mean by saying "important points" ? Can you ask your question more detailed please..?
 
Ayub ali khan
Ranch Hand
Posts: 395
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Sorry I got stuck with work and I could not get back to this thread. I was trying to use the exception frame work provided by java and extend it to provide my own custom exceptions for the web application.

Like

MYExceptionclass extends Exception{

MyBaseException(Exception e){

System.out.println("MyBaseException ;"+e);

}

}

What are the different types of exceptions a web application has to take care of ?

Thanks and Regards
Ayub
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the different types of exceptions a web application has to take care of ?


For one thing, if your code throws an exception that indicates a serious error such that the app is unusable, you should catch it, log the information and throw a javax.servlet.UnavailableException. This will be caught by the servlet container which will then not try to process any more requests directed to that servlet, saving your users lots of confusion.

Bill
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In case the exception is because of something wrong in the request and for some different request it might work then send the user to some more meaningful message.For this you might want to use custom pages and configure those in web.xml.

Throwing UnavailableException would completely cease the servlet out of action for all further requests for this servlet.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rahul Bhattacharjee:
In case the exception is because of something wrong in the request and for some different request it might work then send the user to some more meaningful message.For this you might want to use custom pages and configure those in web.xml.

Throwing UnavailableException would completely cease the servlet out of action for all further requests for this servlet.


There needs to be a distinction made between a validation issue (like the user forgot to enter a zip code) and programming errors. The former should not be handled with exceptions, or if they are, they should be exceptions that are caught and handled in a way that guides the user toward entering the correct data.

Programming errors (such as a misspelling in a form field causing getParameter to return null) on the other hand, once caught should, in most cases stop the servlet in question from serving any more requests until the problem is found and corrected.
 
Ayub ali khan
Ranch Hand
Posts: 395
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thank you all for guiding me and providing good tips on exception handling.


Best Regards
Ayub
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!