NumberFormatException probably isn't a good example because it's an unchecked exception.
Operations that throw checked exceptions have to be dealt with in your code in order for your servlet to be compiled. In these cases, you might want to catch them and re-throw them to let the container deal with them.
If our code is about to throw any checked exception, we should catch it and throw ServletException, so that the code is compilable and also the container can redirect the custom page defined in DD.
If our code is about to throw any checked exception, we should catch it and throw ServletException, so that the code is compilable and also the container can redirect the custom page defined in DD.
Am i right?
Yes, if you don't want to deal with it in your code, you can re-throw it as a servletException.
Originally posted by Shiaber Shaam: A doPost can declare exceptions like ServletException and IOException alone. Otherwise, it won't be compiled.
In this case, which exceptions are the sub classes of ServletException??
The only one provided by the spec is UnavailableException. You can always subclass it with your own exceptions if you like. Or... as mentioned earlier, you can simple re-throw it as a ServletException.
Post by:autobot
Get me the mayor's office! I need to tell him about this tiny ad:
a bit of art, as a gift, that will fit in a stocking