• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Exception Handling frame work

 
Ranch Hand
Posts: 399
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not an advanced question. Moving...
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 399
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 399
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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


Best Regards
Ayub
 
Arch enemy? I mean, I don't like you, but I don't think you qualify as "arch enemy". Here, try this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic