How Will You Implement Error Page in JSP ?

To implement an error-handling page in JSP, we first create a JSP with error page handling information. In most of the cases we gracefully handle error by giving a user-friendly message like "There is system error. Please try again by refreshing page."

In this error page, we show user-friendly message to user, but we also log important information like stack trace to our application log file.

We have to add parameter isErrorPage=true in page directive of this page. This tells to JSP container that this is our error page.

<%@page isErrorPage=”true” %>

Now we can use this error page in other JSP where we want to handle error. In case of an error or exception, these JSP will direct it to errorPage.

<% page errorPage=”ErrorPage.jsp” %>



You May Interest

What is the Difference Between Throw and Throws in Java ?

What are the Uses of AOP Module in Spring Framework ?

Why an Object Used as Key in HashMap Should Be Immutable in Java ...

What is the Importance of hashCode and equals Methods in Java ?

What is an Output Comment in JSP ?