throw new IOException("Some
required files are missing");
Some commonly thrown Exceptions
IllegalArgumentException : If your method only accepts arguments within a
particular range, e.g. only positive numbers, then you should check for invalid
parameters and throw an IllegalArgumentException.
NullPointerException : If you know that a parameter to your method cannot
be null, then it is best to explicitly check for null and throw a
NullPointerException.
IllegalStateException :
This one is a little less common, but is useful a method relies on a previous
method having been called.
UnsupportedOperationException : This exception is designed for cases
where you override an abstract class or implement an interface, but don't want
or can't to implement certain methods.
Runtime Exception :These essentially mean "that should never happen and I
don't know what to do if it does", with different degrees of seriousness. You
basically want the application to "bomb out" of whatever it's doing at that
moment. If essentially the application can go on working after the unexpected
condition, throw a RuntimeException.
Now we are going to develop an JSP application to throw
Exception. For this application we follow the following steps
Steps 1: Create New Project
In this step we select a new project option from File menu.

Step 2: Choose Project
In this step we select a Web Application project from the Java Web Categories and click the
next button.

Step 3: Name and Location
In this step we give a specific name to the project and save it in a specific
location then click on the Next button.







Join the conversation! Your thoughts help the community grow.