JSP exception

tutorial and example
tutorial and example

Like Java, exceptions can also be occurred in JSP. To handle these exceptions, JSP exception object is used.

Handling exceptions in JSP using exception object is much easier approach. This object is needed to be declared in a separate exception page. The exception page path is provided to the current page within page directive.

However, try catch block can also be used to handle these exceptions. 

Example of exception

In this example, we use exception object to handle the exceptions. The result is generated on the basis of division of the provided numbers. If inappropriate number is given in the input then an exception occurs.