index.html
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="process.jsp">
No1:
<input type="text" name="n1" />
<br />
<br />
No1:
<input type="text" name="n2" />
<br />
<br />
<input type="submit" value="divide" />
</form>
</body>
</html>
process.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%@ page errorPage="error.jsp"%>
<%
String num1 = request.getParameter("n1");
String num2 = request.getParameter("n2");
int a = Integer.parseInt(num1);
int b = Integer.parseInt(num2);
int c = a / b;
out.print("division of numbers is: " + c);
%>
</body>
</html>
error.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%@ page isErrorPage="true"%>
<h3>
Sorry an exception occured!
</h3>
Exception is:
<%=exception%>
</body>
</html>
======================================================
=
NOTE
when i insert 4 and 2 in both textbox it gives answer
but
when i insert 4 and 0 or 4 ans a respectively in txtbox ...it does not show error message infact it gives following error