This Java example shows how to handle an exception in JSP using global error page by setting isErrorPage attribute of page directive to true.
Below JSP page displays exception message.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isErrorPage="true" %> <html> <head> <title>Error Page</title> </head> <body> <h1>An error has occurred.</h1> <div style="color: #F00;"> Error message: <%= exception.toString() %> </div> </body> </html> |