Hello Devs,
In this tutorial, we are going to learn Exception Handling Example
exception.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>JSP Exception</title>
</head>
<body>
<%
try{
int array[]={1,2,3,4,5};
int number=array[6];
out.println("7th element of array"+number);
} catch (Exception exp){
out.println("<h3>The number you try to access is not available :</h3> <br>" + exp);
}
%>
</body>
</html>
I hope this example helps you.